Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
078d8f12
Commit
078d8f12
authored
Mar 09, 2019
by
ryan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
table using MultiGrid
parent
343e49de
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
82 additions
and
54 deletions
+82
-54
packages/grafana-ui/src/components/Table/Table.story.tsx
+35
-40
packages/grafana-ui/src/components/Table/Table.test.ts
+2
-2
packages/grafana-ui/src/components/Table/Table.tsx
+0
-0
packages/grafana-ui/src/components/Table/TableXXXX.tsx
+0
-0
packages/grafana-ui/src/components/Table/_Table.scss
+22
-12
packages/grafana-ui/src/utils/storybook/withFullSizeStory.tsx
+23
-0
No files found.
packages/grafana-ui/src/components/Table/Table.story.tsx
View file @
078d8f12
import
React
,
{
FunctionComponent
}
from
'react'
;
// import React
from 'react';
import
{
storiesOf
}
from
'@storybook/react'
;
import
{
storiesOf
}
from
'@storybook/react'
;
import
{
Table
}
from
'./Table'
;
import
{
Table
}
from
'./Table'
;
import
{
migratedTestTable
,
migratedTestStyles
,
simpleTable
}
from
'./examples'
;
import
{
migratedTestTable
,
migratedTestStyles
,
simpleTable
}
from
'./examples'
;
import
{
ScopedVars
}
from
'../../types/index'
;
import
{
ScopedVars
,
TableData
}
from
'../../types/index'
;
import
{
withFullSizeStory
}
from
'../../utils/storybook/withFullSizeStory'
;
import
{
renderComponentWithTheme
}
from
'../../utils/storybook/withTheme'
;
import
{
AutoSizer
}
from
'react-virtualized'
;
const
CenteredStory
:
FunctionComponent
<
{}
>
=
({
children
})
=>
{
return
(
<
div
style=
{
{
width
:
'100%'
,
height
:
'100vh'
,
}
}
>
<
AutoSizer
>
{
({
width
,
height
})
=>
(
<
div
style=
{
{
width
:
`${width}px`
,
height
:
`${height}px`
,
border
:
'1px solid red'
,
}
}
>
<
div
>
Need to pass
{
width
}
/
{
height
}
to the table?
</
div
>
{
children
}
</
div
>
)
}
</
AutoSizer
>
</
div
>
);
};
const
replaceVariables
=
(
value
:
any
,
scopedVars
:
ScopedVars
|
undefined
)
=>
{
const
replaceVariables
=
(
value
:
any
,
scopedVars
:
ScopedVars
|
undefined
)
=>
{
// if (scopedVars) {
// if (scopedVars) {
...
@@ -47,24 +17,49 @@ const replaceVariables = (value: any, scopedVars: ScopedVars | undefined) => {
...
@@ -47,24 +17,49 @@ const replaceVariables = (value: any, scopedVars: ScopedVars | undefined) => {
};
};
storiesOf
(
'UI - Alpha/Table'
,
module
)
storiesOf
(
'UI - Alpha/Table'
,
module
)
.
addDecorator
(
story
=>
<
CenteredStory
>
{
story
()
}
</
CenteredStory
>)
.
add
(
'basic'
,
()
=>
{
.
add
(
'basic'
,
()
=>
{
return
renderComponentWithTheme
(
Table
,
{
return
withFullSizeStory
(
Table
,
{
styles
:
[],
styles
:
[],
data
:
simpleTable
,
data
:
simpleTable
,
replaceVariables
,
replaceVariables
,
showHeader
:
true
,
showHeader
:
true
,
width
:
500
,
height
:
300
,
});
});
})
})
.
add
(
'Test Configuration'
,
()
=>
{
.
add
(
'Test Configuration'
,
()
=>
{
return
renderComponentWithTheme
(
Table
,
{
return
withFullSizeStory
(
Table
,
{
styles
:
migratedTestStyles
,
styles
:
migratedTestStyles
,
data
:
migratedTestTable
,
data
:
migratedTestTable
,
replaceVariables
,
replaceVariables
,
showHeader
:
true
,
showHeader
:
true
,
width
:
500
,
});
height
:
300
,
})
.
add
(
'Lots of cells'
,
()
=>
{
const
data
=
{
columns
:
[],
rows
:
[],
type
:
'table'
,
columnMap
:
{},
}
as
TableData
;
for
(
let
i
=
0
;
i
<
20
;
i
++
)
{
data
.
columns
.
push
({
text
:
'Column '
+
i
,
});
}
for
(
let
r
=
0
;
r
<
500
;
r
++
)
{
const
row
=
[];
for
(
let
i
=
0
;
i
<
20
;
i
++
)
{
row
.
push
(
r
+
i
);
}
data
.
rows
.
push
(
row
);
}
console
.
log
(
'DATA:'
,
data
);
return
withFullSizeStory
(
Table
,
{
styles
:
simpleTable
,
data
,
replaceVariables
,
showHeader
:
true
,
fixedColumnCount
:
1
,
fixedRowCount
:
1
,
});
});
});
});
packages/grafana-ui/src/components/Table/Table.test.ts
View file @
078d8f12
...
@@ -3,9 +3,9 @@ import _ from 'lodash';
...
@@ -3,9 +3,9 @@ import _ from 'lodash';
import
{
getColorDefinitionByName
}
from
'@grafana/ui'
;
import
{
getColorDefinitionByName
}
from
'@grafana/ui'
;
import
{
ScopedVars
}
from
'@grafana/ui/src/types'
;
import
{
ScopedVars
}
from
'@grafana/ui/src/types'
;
import
{
getTheme
}
from
'../../themes'
;
import
{
getTheme
}
from
'../../themes'
;
import
Table
from
'./Table'
;
import
{
migratedTestTable
,
migratedTestStyles
}
from
'./examples'
;
import
{
migratedTestTable
,
migratedTestStyles
}
from
'./examples'
;
import
TableXXXX
from
'./TableXXXX'
;
// TODO: this is commented out with *x* describe!
// TODO: this is commented out with *x* describe!
// Essentially all the elements need to replace the <td> with <div>
// Essentially all the elements need to replace the <td> with <div>
...
@@ -28,7 +28,7 @@ xdescribe('when rendering table', () => {
...
@@ -28,7 +28,7 @@ xdescribe('when rendering table', () => {
};
};
const
table
=
migratedTestTable
;
const
table
=
migratedTestTable
;
const
renderer
=
new
Table
({
const
renderer
=
new
Table
XXXX
({
styles
:
migratedTestStyles
,
styles
:
migratedTestStyles
,
data
:
migratedTestTable
,
data
:
migratedTestTable
,
replaceVariables
,
replaceVariables
,
...
...
packages/grafana-ui/src/components/Table/Table.tsx
View file @
078d8f12
This diff is collapsed.
Click to expand it.
packages/grafana-ui/src/components/Table/TableXXXX.tsx
0 → 100644
View file @
078d8f12
This diff is collapsed.
Click to expand it.
packages/grafana-ui/src/components/Table/_Table.scss
View file @
078d8f12
...
@@ -9,12 +9,6 @@
...
@@ -9,12 +9,6 @@
display
:
flex
;
display
:
flex
;
flex-direction
:
row
;
flex-direction
:
row
;
align-items
:
left
;
align-items
:
left
;
background
:
$list-item-bg
;
border-top
:
2px
solid
$body-bg
;
border-bottom
:
2px
solid
$body-bg
;
color
:
$blue
;
}
}
.ReactVirtualized__Table__row
{
.ReactVirtualized__Table__row
{
display
:
flex
;
display
:
flex
;
...
@@ -37,12 +31,6 @@
...
@@ -37,12 +31,6 @@
margin-right
:
10px
;
margin-right
:
10px
;
min-width
:
0px
;
min-width
:
0px
;
}
}
.ReactVirtualized__Table__rowColumn
{
text-overflow
:
ellipsis
;
white-space
:
nowrap
;
border-right
:
2px
solid
$body-bg
;
}
.ReactVirtualized__Table__headerColumn
:first-of-type
,
.ReactVirtualized__Table__headerColumn
:first-of-type
,
.ReactVirtualized__Table__rowColumn
:first-of-type
{
.ReactVirtualized__Table__rowColumn
:first-of-type
{
...
@@ -62,3 +50,25 @@
...
@@ -62,3 +50,25 @@
width
:
1em
;
width
:
1em
;
fill
:
currentColor
;
fill
:
currentColor
;
}
}
.gf-table-header
{
padding
:
3px
10px
;
background
:
$list-item-bg
;
border-top
:
2px
solid
$body-bg
;
border-bottom
:
2px
solid
$body-bg
;
cursor
:
pointer
;
color
:
$blue
;
}
.gf-table-cell
{
padding
:
3px
10px
;
text-overflow
:
ellipsis
;
white-space
:
nowrap
;
border-right
:
2px
solid
$body-bg
;
border-bottom
:
2px
solid
$body-bg
;
}
packages/grafana-ui/src/utils/storybook/withFullSizeStory.tsx
0 → 100644
View file @
078d8f12
import
React
from
'react'
;
import
{
AutoSizer
}
from
'react-virtualized'
;
export
const
withFullSizeStory
=
(
component
:
React
.
ComponentType
<
any
>
,
props
:
any
)
=>
(
<
div
style=
{
{
height
:
'100vh'
,
width
:
'100%'
,
}
}
>
<
AutoSizer
>
{
({
width
,
height
})
=>
(
<>
{
React
.
createElement
(
component
,
{
...
props
,
width
,
height
,
})
}
</>
)
}
</
AutoSizer
>
</
div
>
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment