Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit 8a47d6e

Browse files
authored
feat(Input): move styles to Base theme (#1247)
* feat(Input): move styles to Base theme * fix regressions, update Base * remove broken themes * add clearable snapshot * move changelog entry * remove duplicate changes
1 parent 592845c commit 8a47d6e

File tree

9 files changed

+90
-44
lines changed

9 files changed

+90
-44
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
1717

1818
## [Unreleased]
1919

20+
### BREAKING CHANGES
21+
- Rename `inputFocusBorderBottomColor` to `inputFocusBorderColor` in `InputVariables` @layershifter ([#1247](https://github.com/stardust-ui/react/pull/1247))
22+
23+
### Features
24+
- Move `Input` styles to Base theme @layershifter ([#1247](https://github.com/stardust-ui/react/pull/1247))
25+
2026
<!--------------------------------[ v0.28.1 ]------------------------------- -->
2127
## [v0.28.1](https://github.com/stardust-ui/react/tree/v0.28.1) (2019-04-23)
2228
[Compare changes](https://github.com/stardust-ui/react/compare/v0.28.0...v0.28.1)

docs/src/examples/components/Input/Types/InputExample.shorthand.steps.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Input } from '@stardust-ui/react'
22

33
const config: ScreenerTestsConfig = {
44
steps: [builder => builder.focus(`.${Input.className} input`).snapshot('Can be focused')],
5+
themes: ['teams', 'base'],
56
}
67

78
export default config
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Input } from '@stardust-ui/react'
2+
3+
const config: ScreenerTestsConfig = {
4+
steps: [
5+
builder =>
6+
builder.setValue(`.${Input.className} input`, 'Some text...').snapshot('Can be clearable'),
7+
],
8+
themes: ['teams', 'base'],
9+
}
10+
11+
export default config

packages/react/src/themes/base/componentStyles.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ export { default as FlexItem } from './components/Flex/flexItemStyles'
55

66
export { default as Icon } from './components/Icon/iconStyles'
77

8+
export { default as Input } from './components/Input/inputStyles'
9+
810
export { default as Loader } from './components/Loader/loaderStyles'
911

1012
export { default as ProviderBox } from './components/Provider/providerBoxStyles'

packages/react/src/themes/base/componentVariables.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ export { default as FlexItem } from './components/Flex/flexItemVariables'
55

66
export { default as Icon } from './components/Icon/iconVariables'
77

8+
export { default as Input } from './components/Input/inputVariables'
9+
810
export { default as Loader } from './components/Loader/loaderVariables'
911

1012
export { default as ProviderBox } from './components/Provider/providerBoxVariables'

packages/react/src/themes/teams/components/Input/inputStyles.ts renamed to packages/react/src/themes/base/components/Input/inputStyles.ts

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,36 @@ import { PositionProperty } from 'csstype'
55

66
const inputStyles: ComponentSlotStylesInput<InputProps, InputVariables> = {
77
root: ({ props: p }): ICSSInJSStyle => ({
8+
alignItems: 'center',
89
display: 'inline-flex',
910
position: 'relative',
10-
alignItems: 'center',
1111
outline: 0,
12+
1213
...(p.fluid && { width: '100%' }),
1314
}),
1415

1516
input: ({ props: p, variables: v }): ICSSInJSStyle => ({
16-
outline: 0,
17+
backgroundColor: v.backgroundColor,
18+
color: v.fontColor,
19+
20+
borderColor: v.borderColor,
21+
borderRadius: v.borderRadius,
1722
borderStyle: 'solid',
18-
borderColor: 'transparent',
1923
borderWidth: v.borderWidth,
20-
borderRadius: v.borderRadius,
21-
color: v.fontColor,
22-
backgroundColor: v.backgroundColor,
23-
position: 'relative',
24+
25+
outline: 0,
2426
padding: v.inputPadding,
27+
position: 'relative',
28+
2529
...(p.fluid && { width: '100%' }),
2630
...(p.inline && { float: 'left' }),
31+
2732
'::placeholder': {
2833
color: v.placeholderColor,
2934
},
35+
3036
':focus': {
31-
borderBottomColor: v.inputFocusBorderBottomColor,
37+
borderColor: v.inputFocusBorderColor,
3238
},
3339
...(p.clearable && { padding: v.inputPaddingWithIconAtEnd }),
3440
...(p.icon && {
@@ -37,16 +43,17 @@ const inputStyles: ComponentSlotStylesInput<InputProps, InputVariables> = {
3743
}),
3844
}),
3945

40-
icon: ({ props: { iconPosition }, variables: v }): ICSSInJSStyle => ({
41-
position: v.iconPosition as PositionProperty,
46+
icon: ({ props: p, variables: v }): ICSSInJSStyle => ({
4247
color: v.iconColor,
43-
...(iconPosition === 'start' && {
48+
outline: 0,
49+
position: v.iconPosition as PositionProperty,
50+
51+
...(p.iconPosition === 'start' && {
4452
left: v.iconLeft,
4553
}),
46-
...(iconPosition === 'end' && {
54+
...(p.iconPosition === 'end' && {
4755
right: v.iconRight,
4856
}),
49-
outline: 0,
5057
}),
5158
}
5259

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { pxToRem } from '../../../../lib'
2+
3+
export interface InputVariables {
4+
backgroundColor: string
5+
borderColor: string
6+
borderRadius: string
7+
borderWidth: string
8+
fontColor: string
9+
fontSize: string
10+
iconColor: string
11+
iconPosition: string
12+
iconRight: string
13+
iconLeft: string
14+
inputPaddingWithIconAtStart: string
15+
inputPaddingWithIconAtEnd: string
16+
inputPadding: string
17+
inputFocusBorderColor: string
18+
inputFocusBorderRadius: string
19+
placeholderColor: string
20+
}
21+
22+
export default (siteVars): InputVariables => ({
23+
backgroundColor: siteVars.colors.grey[50],
24+
borderColor: siteVars.colors.grey[300],
25+
borderRadius: pxToRem(3),
26+
borderWidth: `1px`,
27+
28+
fontColor: siteVars.colors.grey[600],
29+
fontSize: pxToRem(14),
30+
31+
iconPosition: 'absolute',
32+
iconRight: pxToRem(10),
33+
iconColor: siteVars.colors.grey[800],
34+
iconLeft: pxToRem(6),
35+
inputPaddingWithIconAtStart: `${pxToRem(7)} ${pxToRem(12)} ${pxToRem(7)} ${pxToRem(24)}`,
36+
inputPaddingWithIconAtEnd: `${pxToRem(7)} ${pxToRem(24)} ${pxToRem(7)} ${pxToRem(12)}`,
37+
38+
inputPadding: `${pxToRem(7)} ${pxToRem(12)}`,
39+
inputFocusBorderColor: siteVars.colors.primary[300],
40+
inputFocusBorderRadius: pxToRem(3),
41+
42+
placeholderColor: siteVars.colors.grey[600],
43+
})

packages/react/src/themes/teams/componentStyles.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ export { default as HeaderDescription } from './components/Header/headerDescript
3434

3535
export { default as Icon } from './components/Icon/iconStyles'
3636

37-
export { default as Input } from './components/Input/inputStyles'
38-
3937
export { default as Label } from './components/Label/labelStyles'
4038

4139
export { default as Layout } from './components/Layout/layoutStyles'
Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,17 @@
1+
import { InputVariables } from '../../../base/components/Input/inputVariables'
12
import { pxToRem } from '../../../../lib'
23

3-
export interface InputVariables {
4-
backgroundColor: string
5-
borderRadius: string
6-
borderWidth: string
7-
fontColor: string
8-
fontSize: string
9-
iconColor: string
10-
iconPosition: string
11-
iconRight: string
12-
iconLeft: string
13-
inputPaddingWithIconAtStart: string
14-
inputPaddingWithIconAtEnd: string
15-
inputPadding: string
16-
inputFocusBorderBottomColor: string
17-
inputFocusBorderRadius: string
18-
placeholderColor: string
19-
}
20-
21-
export default (siteVars): InputVariables => ({
22-
backgroundColor: siteVars.gray10,
4+
export default (siteVars): Partial<InputVariables> => ({
5+
borderColor: 'transparent',
236
borderRadius: `${pxToRem(3)} ${pxToRem(3)} ${pxToRem(2)} ${pxToRem(2)}`,
247
borderWidth: `0 0 ${pxToRem(2)} 0`,
8+
backgroundColor: siteVars.gray10,
259

2610
fontColor: siteVars.gray02,
2711
fontSize: siteVars.fontSizes.medium,
2812

29-
iconPosition: 'absolute',
30-
iconRight: pxToRem(10),
3113
iconColor: siteVars.bodyColor,
32-
iconLeft: pxToRem(6),
33-
inputPaddingWithIconAtStart: `${pxToRem(7)} ${pxToRem(12)} ${pxToRem(7)} ${pxToRem(24)}`,
34-
inputPaddingWithIconAtEnd: `${pxToRem(7)} ${pxToRem(24)} ${pxToRem(7)} ${pxToRem(12)}`,
35-
36-
inputPadding: `${pxToRem(7)} ${pxToRem(12)}`,
37-
inputFocusBorderBottomColor: siteVars.colors.primary[500],
14+
inputFocusBorderColor: `transparent transparent ${siteVars.colors.primary[500]} transparent`,
3815
inputFocusBorderRadius: `${pxToRem(3)} ${pxToRem(3)} ${pxToRem(2)} ${pxToRem(2)}`,
39-
4016
placeholderColor: siteVars.gray02,
4117
})

0 commit comments

Comments
 (0)