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
65d97edb
Unverified
Commit
65d97edb
authored
Mar 25, 2020
by
Ivana Huckova
Committed by
GitHub
Mar 25, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create ComponentSize type and replace ButtonSize with it (#23059)
parent
d6b6b0f2
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
27 additions
and
23 deletions
+27
-23
packages/grafana-ui/src/components/Button/Button.tsx
+3
-2
packages/grafana-ui/src/components/Button/ButtonContent.tsx
+2
-2
packages/grafana-ui/src/components/Button/styles.ts
+3
-2
packages/grafana-ui/src/components/Button/types.ts
+2
-3
packages/grafana-ui/src/components/ConfirmButton/ConfirmButton.tsx
+3
-2
packages/grafana-ui/src/components/ConfirmButton/DeleteButton.tsx
+2
-2
packages/grafana-ui/src/components/Forms/Button.story.tsx
+2
-2
packages/grafana-ui/src/components/Forms/Button.tsx
+3
-2
packages/grafana-ui/src/components/Forms/Select/ButtonSelect.tsx
+2
-2
packages/grafana-ui/src/components/Forms/commonStyles.ts
+2
-2
packages/grafana-ui/src/components/Forms/getFormStyles.ts
+2
-2
packages/grafana-ui/src/types/size.ts
+1
-0
No files found.
packages/grafana-ui/src/components/Button/Button.tsx
View file @
65d97edb
...
...
@@ -2,11 +2,12 @@ import React, { AnchorHTMLAttributes, ButtonHTMLAttributes, useContext } from 'r
import
{
ThemeContext
}
from
'../../themes'
;
import
{
getButtonStyles
}
from
'./styles'
;
import
{
ButtonContent
}
from
'./ButtonContent'
;
import
{
ButtonSize
,
ButtonStyles
,
ButtonVariant
}
from
'./types'
;
import
{
ComponentSize
}
from
'../../types/size'
;
import
{
ButtonStyles
,
ButtonVariant
}
from
'./types'
;
import
{
cx
}
from
'emotion'
;
type
CommonProps
=
{
size
?:
Button
Size
;
size
?:
Component
Size
;
variant
?:
ButtonVariant
;
/**
* icon prop is a temporary solution. It accepts legacy icon class names for the icon to be rendered.
...
...
packages/grafana-ui/src/components/Button/ButtonContent.tsx
View file @
65d97edb
import
React
from
'react'
;
import
{
css
}
from
'emotion'
;
import
{
stylesFactory
,
useTheme
}
from
'../../themes'
;
import
{
ComponentSize
}
from
'../../types/size'
;
import
{
GrafanaTheme
}
from
'@grafana/data'
;
import
{
ButtonSize
}
from
'./types'
;
const
getStyles
=
stylesFactory
((
theme
:
GrafanaTheme
)
=>
({
content
:
css
`
...
...
@@ -26,7 +26,7 @@ type Props = {
icon
?:
string
;
className
?:
string
;
children
:
React
.
ReactNode
;
size
?:
Button
Size
;
size
?:
Component
Size
;
};
export
function
ButtonContent
(
props
:
Props
)
{
...
...
packages/grafana-ui/src/components/Button/styles.ts
View file @
65d97edb
import
tinycolor
from
'tinycolor2'
;
import
{
css
}
from
'emotion'
;
import
{
selectThemeVariant
,
stylesFactory
}
from
'../../themes'
;
import
{
StyleDeps
,
ButtonSize
}
from
'./types'
;
import
{
ComponentSize
}
from
'../../types/size'
;
import
{
StyleDeps
}
from
'./types'
;
import
{
GrafanaTheme
}
from
'@grafana/data'
;
const
buttonVariantStyles
=
(
...
...
@@ -116,7 +117,7 @@ type ButtonMeasures = {
fontWeight
:
number
;
};
const
calculateMeasures
=
(
theme
:
GrafanaTheme
,
size
:
Button
Size
,
textAndIcon
:
boolean
):
ButtonMeasures
=>
{
const
calculateMeasures
=
(
theme
:
GrafanaTheme
,
size
:
Component
Size
,
textAndIcon
:
boolean
):
ButtonMeasures
=>
{
switch
(
size
)
{
case
'sm'
:
{
return
{
...
...
packages/grafana-ui/src/components/Button/types.ts
View file @
65d97edb
import
{
GrafanaTheme
}
from
'@grafana/data'
;
import
{
ComponentSize
}
from
'../../types/size'
;
export
type
ButtonVariant
=
'primary'
|
'secondary'
|
'danger'
|
'inverse'
|
'transparent'
|
'destructive'
|
'link'
;
export
type
ButtonSize
=
'xs'
|
'sm'
|
'md'
|
'lg'
;
export
interface
StyleDeps
{
theme
:
GrafanaTheme
;
size
:
Button
Size
;
size
:
Component
Size
;
variant
:
ButtonVariant
;
textAndIcon
?:
boolean
;
}
...
...
packages/grafana-ui/src/components/ConfirmButton/ConfirmButton.tsx
View file @
65d97edb
...
...
@@ -3,9 +3,10 @@ import { cx, css } from 'emotion';
import
{
stylesFactory
,
withTheme
}
from
'../../themes'
;
import
{
GrafanaTheme
}
from
'@grafana/data'
;
import
{
Themeable
}
from
'../../types'
;
import
{
ComponentSize
}
from
'../../types/size'
;
import
{
Button
}
from
'../Button/Button'
;
import
Forms
from
'../Forms'
;
import
{
ButtonVariant
,
ButtonSize
}
from
'../Button/types'
;
import
{
ButtonVariant
}
from
'../Button/types'
;
const
getStyles
=
stylesFactory
((
theme
:
GrafanaTheme
)
=>
{
return
{
...
...
@@ -55,7 +56,7 @@ const getStyles = stylesFactory((theme: GrafanaTheme) => {
interface
Props
extends
Themeable
{
className
?:
string
;
size
?:
Button
Size
;
size
?:
Component
Size
;
confirmText
?:
string
;
disabled
?:
boolean
;
confirmVariant
?:
ButtonVariant
;
...
...
packages/grafana-ui/src/components/ConfirmButton/DeleteButton.tsx
View file @
65d97edb
import
React
,
{
FC
}
from
'react'
;
import
{
ConfirmButton
}
from
'./ConfirmButton'
;
import
{
Button
}
from
'../Button/Button'
;
import
{
ButtonSize
}
from
'../Button/types
'
;
import
{
ComponentSize
}
from
'../../types/size
'
;
interface
Props
{
size
?:
Button
Size
;
size
?:
Component
Size
;
disabled
?:
boolean
;
onConfirm
():
void
;
}
...
...
packages/grafana-ui/src/components/Forms/Button.story.tsx
View file @
65d97edb
...
...
@@ -3,7 +3,7 @@ import { select, text } from '@storybook/addon-knobs';
import
{
Button
,
ButtonVariant
}
from
'./Button'
;
import
{
withCenteredStory
,
withHorizontallyCenteredStory
}
from
'../../utils/storybook/withCenteredStory'
;
import
{
getIconKnob
}
from
'../../utils/storybook/knobs'
;
import
{
ButtonSize
}
from
'../Button/types
'
;
import
{
ComponentSize
}
from
'../../types/size
'
;
import
mdx
from
'./Button.mdx'
;
export
default
{
...
...
@@ -28,7 +28,7 @@ export const simple = () => {
const
icon
=
getIconKnob
();
return
(
<
Button
variant=
{
variant
as
ButtonVariant
}
size=
{
size
as
Button
Size
}
icon=
{
icon
&&
`fa fa-${icon}`
}
>
<
Button
variant=
{
variant
as
ButtonVariant
}
size=
{
size
as
Component
Size
}
icon=
{
icon
&&
`fa fa-${icon}`
}
>
{
buttonText
}
</
Button
>
);
...
...
packages/grafana-ui/src/components/Forms/Button.tsx
View file @
65d97edb
...
...
@@ -4,7 +4,8 @@ import tinycolor from 'tinycolor2';
import
{
selectThemeVariant
,
stylesFactory
,
ThemeContext
}
from
'../../themes'
;
import
{
Button
as
DefaultButton
,
LinkButton
as
DefaultLinkButton
}
from
'../Button/Button'
;
import
{
getFocusStyle
,
getPropertiesForButtonSize
}
from
'./commonStyles'
;
import
{
ButtonSize
,
StyleDeps
}
from
'../Button/types'
;
import
{
ComponentSize
}
from
'../../types/size'
;
import
{
StyleDeps
}
from
'../Button/types'
;
import
{
GrafanaTheme
}
from
'@grafana/data'
;
const
buttonVariantStyles
=
(
from
:
string
,
to
:
string
,
textColor
:
string
)
=>
css
`
...
...
@@ -130,7 +131,7 @@ export type ButtonVariant = 'primary' | 'secondary' | 'destructive' | 'link';
// These also needs to be different because the ButtonVariant is different
type
CommonProps
=
{
size
?:
Button
Size
;
size
?:
Component
Size
;
variant
?:
ButtonVariant
;
icon
?:
string
;
className
?:
string
;
...
...
packages/grafana-ui/src/components/Forms/Select/ButtonSelect.tsx
View file @
65d97edb
...
...
@@ -3,7 +3,7 @@ import { css } from 'emotion';
import
{
GrafanaTheme
}
from
'@grafana/data'
;
import
{
Button
,
ButtonVariant
,
ButtonProps
}
from
'../Button'
;
import
{
ButtonSize
}
from
'../../Button/types
'
;
import
{
ComponentSize
}
from
'../../../types/size
'
;
import
{
SelectCommonProps
,
CustomControlProps
}
from
'./types'
;
import
{
SelectBase
}
from
'./SelectBase'
;
import
{
stylesFactory
,
useTheme
}
from
'../../../themes'
;
...
...
@@ -13,7 +13,7 @@ import { IconType } from '../../Icon/types';
interface
ButtonSelectProps
<
T
>
extends
Omit
<
SelectCommonProps
<
T
>
,
'renderControl'
|
'size'
|
'prefix'
>
{
icon
?:
IconType
;
variant
?:
ButtonVariant
;
size
?:
Button
Size
;
size
?:
Component
Size
;
}
interface
SelectButtonProps
extends
Omit
<
ButtonProps
,
'icon'
>
{
...
...
packages/grafana-ui/src/components/Forms/commonStyles.ts
View file @
65d97edb
import
{
css
}
from
'emotion'
;
import
{
GrafanaTheme
}
from
'@grafana/data'
;
import
{
ButtonSize
}
from
'../Button/types
'
;
import
{
ComponentSize
}
from
'../../types/size
'
;
export
const
getFocusCss
=
(
theme
:
GrafanaTheme
)
=>
`
outline: 2px dotted transparent;
...
...
@@ -90,7 +90,7 @@ export const inputSizesPixels = (size: string) => {
}
};
export
const
getPropertiesForButtonSize
=
(
theme
:
GrafanaTheme
,
size
:
Button
Size
)
=>
{
export
const
getPropertiesForButtonSize
=
(
theme
:
GrafanaTheme
,
size
:
Component
Size
)
=>
{
switch
(
size
)
{
case
'sm'
:
return
{
...
...
packages/grafana-ui/src/components/Forms/getFormStyles.ts
View file @
65d97edb
...
...
@@ -4,13 +4,13 @@ import { getLabelStyles } from './Label';
import
{
getLegendStyles
}
from
'./Legend'
;
import
{
getFieldValidationMessageStyles
}
from
'./FieldValidationMessage'
;
import
{
getButtonStyles
,
ButtonVariant
}
from
'./Button'
;
import
{
ButtonSize
}
from
'../Button/types
'
;
import
{
ComponentSize
}
from
'../../types/size
'
;
import
{
getInputStyles
}
from
'./Input/Input'
;
import
{
getSwitchStyles
}
from
'./Switch'
;
import
{
getCheckboxStyles
}
from
'./Checkbox'
;
export
const
getFormStyles
=
stylesFactory
(
(
theme
:
GrafanaTheme
,
options
:
{
variant
:
ButtonVariant
;
size
:
Button
Size
;
invalid
:
boolean
})
=>
{
(
theme
:
GrafanaTheme
,
options
:
{
variant
:
ButtonVariant
;
size
:
Component
Size
;
invalid
:
boolean
})
=>
{
return
{
label
:
getLabelStyles
(
theme
),
legend
:
getLegendStyles
(
theme
),
...
...
packages/grafana-ui/src/types/size.ts
0 → 100644
View file @
65d97edb
export
type
ComponentSize
=
'xs'
|
'sm'
|
'md'
|
'lg'
;
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