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

Commit 8a3fbed

Browse files
authored
refactor(Divider): remove type prop (#558)
* breaking(Divider): remove `type` prop * add entry to changelog * restore styling changes * restore styling changes * update changelog * restore styling changes * omit divider * move to separate variant
1 parent 645cead commit 8a3fbed

File tree

16 files changed

+39
-109
lines changed

16 files changed

+39
-109
lines changed

CHANGELOG.md

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

1818
## [Unreleased]
1919

20+
### BREAKING CHANGES
21+
- `type` prop is replaced with `color` in `Divider` component @layershifter ([#558](https://github.com/stardust-ui/react/pull/558))
22+
2023
### Fixes
2124
- Fix `Provider` is not executing staticStyles with the merged siteVariables @mnajdova ([#559](https://github.com/stardust-ui/react/pull/559))
2225

docs/src/examples/components/Chat/Types/ChatExample.shorthand.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const items = [
4747
key: 'message-id-4',
4848
},
4949
{
50-
content: <Divider content="Today" type="primary" important />,
50+
content: <Divider content="Today" color="primary" important />,
5151
key: 'message-id-5',
5252
},
5353
{

docs/src/examples/components/Chat/Types/ChatExample.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const ChatExample = () => (
3636
/>
3737
</Chat.Item>
3838
<Chat.Item>
39-
<Divider content="Today" type="primary" important />
39+
<Divider content="Today" color="primary" important />
4040
</Chat.Item>
4141
<Chat.Item>
4242
<Chat.Message

docs/src/examples/components/Divider/Types/DividerExamplePrimary.shorthand.tsx

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/src/examples/components/Divider/Types/DividerExamplePrimary.tsx

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/src/examples/components/Divider/Types/DividerExampleSecondary.shorthand.tsx

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/src/examples/components/Divider/Types/DividerExampleSecondary.tsx

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/src/examples/components/Divider/Types/index.tsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,6 @@ const Types = () => (
1414
description="A Divider can contain text or other content displayed alongside with the line."
1515
examplePath="components/Divider/Types/DividerExampleContent"
1616
/>
17-
<ComponentExample
18-
title="Primary divider"
19-
description="A primary Divider catches the user's attention."
20-
examplePath="components/Divider/Types/DividerExamplePrimary"
21-
/>
22-
<ComponentExample
23-
title="Secondary divider"
24-
description="A secondary Divider is more subtle and less noticeable."
25-
examplePath="components/Divider/Types/DividerExampleSecondary"
26-
/>
2717
</ExampleSection>
2818
)
2919

docs/src/prototypes/chatPane/services/messageFactoryMock.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ function createMessageContentWithAttachments(content: string, messageId: string)
122122
}
123123

124124
function generateDividerProps(props: DividerProps): Divider {
125-
const { content, important, type = 'secondary' } = props
126-
const dividerProps: Divider = { itemType: ChatItemTypes.divider, content, important, type }
125+
const { content, important, color = 'secondary' } = props
126+
const dividerProps: Divider = { itemType: ChatItemTypes.divider, content, important, color }
127127

128128
return dividerProps
129129
}
@@ -158,7 +158,7 @@ export function generateChatProps(chat: ChatData): ChatItemContentProps[] {
158158
chatProps.splice(
159159
myLastMsgIndex + 1,
160160
0,
161-
generateDividerProps({ content: 'Last read', type: 'primary', important: true }),
161+
generateDividerProps({ content: 'Last read', color: 'primary', important: true }),
162162
)
163163
}
164164

docs/src/views/Theming.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ export default () => (
3939
<ExampleSnippet
4040
render={() => (
4141
<Provider theme={{ siteVariables: { brand: 'hotpink' } }}>
42-
<div>
43-
<Button primary>Branding</Button>
44-
<Divider type="primary">Branding</Divider>
45-
</div>
42+
<Button primary>Branding</Button>
4643
</Provider>
4744
)}
4845
/>

docs/src/views/ThemingExamples.tsx

Lines changed: 16 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default () => (
4444
<ExampleSnippet
4545
value={`
4646
import React from 'react'
47-
import { Button, Divider, Icon, Label, Provider } from '@stardust-ui/react'
47+
import { Button, Icon, Label, Provider } from '@stardust-ui/react'
4848
4949
export default () =>
5050
<Provider>
@@ -54,9 +54,6 @@ export default () => (
5454
<Button icon="at" content="Send email" secondary />
5555
<Icon name="chess rook" size="big" />
5656
<Label content="Label with icon" icon="close" />
57-
<br/><br/>
58-
<Divider content="Primary Divider" type="primary" />
59-
<Divider content="Secondary Divider" type="secondary" />
6057
</>
6158
</Provider>
6259
`}
@@ -67,10 +64,6 @@ export default () => (
6764
<Button icon="at" content="Send email" secondary />
6865
<Icon name="chess rook" size="big" />
6966
<Label content="Label with icon" icon="close" />
70-
<br />
71-
<br />
72-
<Divider content="Primary Divider" type="primary" />
73-
<Divider content="Secondary Divider" type="secondary" />
7467
</>
7568
)}
7669
/>
@@ -90,20 +83,21 @@ export default () => (
9083
import { Button } from '@stardust-ui/react'
9184
9285
const styles = {
93-
color: "coral",
94-
backgroundColor: "coral",
95-
fontSize: "14px",
96-
padding: "0 10px",
97-
}
86+
color: "coral",
87+
backgroundColor: "coral",
88+
fontSize: "14px",
89+
padding: "0 10px",
90+
}
9891
const btnExample = () =>
99-
<Button
100-
content="Send email"
101-
icon={{
102-
name: "at",
103-
styles: { color: "brown" },
104-
}}
105-
secondary
106-
styles={styles} />
92+
<Button
93+
content="Send email"
94+
icon={{
95+
name: "at",
96+
styles: { color: "brown" },
97+
}}
98+
secondary
99+
styles={styles}
100+
/>
107101
108102
export default btnExample
109103
`}
@@ -187,7 +181,7 @@ export default () => (
187181
<ExampleSnippet
188182
value={`
189183
import React from 'react'
190-
import { Button, Divider, Icon, Label, Provider } from '@stardust-ui/react'
184+
import { Button, Icon, Label, Provider } from '@stardust-ui/react'
191185
192186
const theme = {
193187
siteVariables: {
@@ -226,9 +220,6 @@ export default () => (
226220
<Button icon="at" content="Send email" secondary />
227221
<Icon name="chess rook" size="big" />
228222
<Label content="Label with icon" icon="close" />
229-
<br /><br />
230-
<Divider type="primary">Branding primary</Divider>
231-
<Divider type="secondary">Branding secondary</Divider>
232223
</div>
233224
</Provider>
234225
)
@@ -273,10 +264,6 @@ export default () => (
273264
<Button icon="at" content="Send email" secondary />
274265
<Icon name="chess rook" size="big" />
275266
<Label content="Label with icon" icon="close" />
276-
<br />
277-
<br />
278-
<Divider content="Primary Divider" type="primary" />
279-
<Divider content="Secondary Divider" type="secondary" />
280267
</div>
281268
</Provider>
282269
</div>
@@ -294,7 +281,6 @@ export default () => (
294281
/* Default theming */
295282
<Header as="h3" content="Default" />
296283
<Button primary>Branding</Button>
297-
<Divider type="primary">Branding</Divider>
298284
299285
/* First nested theming */
300286
<Provider
@@ -310,9 +296,6 @@ export default () => (
310296
<Button icon="at" content="Send email" secondary />
311297
<Icon name="chess rook" size="big" />
312298
<Label content="Label with icon" icon="close" />
313-
<br/><br/>
314-
<Divider content="Primary Divider" type="primary" />
315-
<Divider content="Secondary Divider" type="secondary" />
316299
317300
/* Second nested theming */
318301
<Provider
@@ -332,9 +315,6 @@ export default () => (
332315
<Button icon="at" content="Send email" secondary />
333316
<Icon name="chess rook" size="big" />
334317
<Label content="Label with icon" icon="close" />
335-
<br/><br/>
336-
<Divider content="Primary Divider" type="primary" />
337-
<Divider content="Secondary Divider" type="secondary" />
338318
</div>
339319
</Provider>
340320
</div>
@@ -349,10 +329,6 @@ export default () => (
349329
<Button icon="at" content="Send email" secondary />
350330
<Icon name="chess rook" size="big" />
351331
<Label content="Label with icon" icon="close" />
352-
<br />
353-
<br />
354-
<Divider content="Primary Divider" type="primary" />
355-
<Divider content="Secondary Divider" type="secondary" />
356332

357333
<Provider
358334
theme={{
@@ -367,10 +343,6 @@ export default () => (
367343
<Button icon="at" content="Send email" secondary />
368344
<Icon name="chess rook" size="big" />
369345
<Label content="Label with icon" icon="close" />
370-
<br />
371-
<br />
372-
<Divider content="Primary Divider" type="primary" />
373-
<Divider content="Secondary Divider" type="secondary" />
374346

375347
<Provider
376348
theme={{
@@ -389,10 +361,6 @@ export default () => (
389361
<Button icon="at" content="Send email" secondary />
390362
<Icon name="chess rook" size="big" />
391363
<Label content="Label with icon" icon="close" />
392-
<br />
393-
<br />
394-
<Divider content="Primary Divider" type="primary" />
395-
<Divider content="Secondary Divider" type="secondary" />
396364
</>
397365
</Provider>
398366
</>

src/components/Divider/Divider.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ export interface DividerProps
2424
/** Size multiplier (default 0) * */
2525
size?: number
2626

27-
/** A Divider can be formatted to show different levels of emphasis. */
28-
type?: 'primary' | 'secondary'
29-
3027
/** A divider can appear more important and draw the user's attention. */
3128
important?: boolean
3229
}
@@ -45,7 +42,6 @@ class Divider extends UIComponent<Extendable<DividerProps>, any> {
4542
...commonPropTypes.createCommon({ color: true }),
4643
fitted: PropTypes.bool,
4744
size: PropTypes.number,
48-
type: PropTypes.oneOf(['primary', 'secondary']),
4945
important: PropTypes.bool,
5046
}
5147

src/themes/teams-dark/components/Divider/dividerVariables.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { DividerVariables } from '../../../teams/components/Divider/dividerVaria
22
import { Partial } from 'types/utils'
33

44
export default (siteVars: any): Partial<DividerVariables> => ({
5-
primaryColor: siteVars.brand06,
5+
colors: {
6+
primary: siteVars.brand06,
7+
},
68
textColor: siteVars.gray02,
79
})

src/themes/teams-high-contrast/components/Divider/dividerVariables.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import { DividerVariables } from '../../../teams/components/Divider/dividerVaria
22
import { Partial } from 'types/utils'
33

44
export default (siteVars: any): Partial<DividerVariables> => ({
5+
colors: {
6+
primary: siteVars.white,
7+
},
58
dividerColor: siteVars.white,
69
textColor: siteVars.white,
7-
primaryColor: siteVars.white,
810
})

src/themes/teams/components/Divider/dividerStyles.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ const beforeAndAfter = (color, size, type, variables): ICSSPseudoElementStyle =>
1414
flex: 1,
1515
...dividerBorderStyle(size, variables.dividerColor),
1616
...(color && {
17-
...dividerBorderStyle(size, _.get(variables.colors, [color, 500])),
18-
}),
19-
...(type === 'primary' && {
20-
...dividerBorderStyle(size, variables.primaryColor),
17+
...dividerBorderStyle(size, _.get(variables.colors, color)),
2118
}),
2219
})
2320

@@ -33,10 +30,7 @@ const dividerStyles: ComponentSlotStylesInput<DividerPropsWithDefaults, any> = {
3330
paddingBottom: variables.dividerPadding,
3431
}),
3532
...(color && {
36-
color: _.get(variables.colors, [color, 500]),
37-
}),
38-
...(type === 'primary' && {
39-
color: variables.primaryColor,
33+
color: _.get(variables.colors, color),
4034
}),
4135
...(important && {
4236
fontWeight: variables.importantFontWeight,

src/themes/teams/components/Divider/dividerVariables.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
1+
import * as _ from 'lodash'
2+
13
import { EmphasisColors, NaturalColors } from '../../../types'
24
import { pxToRem } from '../../../../lib'
35

46
export interface DividerVariables {
5-
colors: EmphasisColors & NaturalColors
7+
colors: Record<keyof (EmphasisColors & NaturalColors), string>
68
dividerColor: string
79
textColor: string
810
textFontSize: string
911
textLineHeight: string
10-
primaryColor: string
1112
importantFontWeight: string
1213
dividerPadding: string
1314
}
1415

1516
export default (siteVars: any): DividerVariables => {
17+
const colorVariant = '500'
18+
1619
return {
17-
colors: { ...siteVars.emphasisColors, ...siteVars.naturalColors },
20+
colors: _.mapValues({ ...siteVars.emphasisColors, ...siteVars.naturalColors }, colorVariant),
1821
dividerColor: siteVars.gray09,
1922
textColor: siteVars.gray03,
2023
textFontSize: siteVars.fontSizeSmall,
2124
textLineHeight: siteVars.lineHeightSmall,
22-
primaryColor: siteVars.brand,
2325
importantFontWeight: siteVars.fontWeightBold,
2426
dividerPadding: pxToRem(4),
2527
}

0 commit comments

Comments
 (0)