This repository was archived by the owner on Mar 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
feat(header): header and header description color prop #628
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
docs/src/examples/components/Header/Variations/HeaderExampleColor.shorthand.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react' | ||
import _ from 'lodash' | ||
import { Header, ProviderConsumer } from '@stardust-ui/react' | ||
|
||
const HeaderExampleColor = () => ( | ||
<ProviderConsumer | ||
render={({ siteVariables: { emphasisColors, naturalColors } }) => | ||
_.keys({ ...emphasisColors, ...naturalColors }).map(color => ( | ||
<Header | ||
key={color} | ||
as="h4" | ||
color={color} | ||
content={_.startCase(color)} | ||
description={{ content: `Description of ${_.lowerCase(color)} color`, color }} | ||
/> | ||
)) | ||
} | ||
/> | ||
) | ||
|
||
export default HeaderExampleColor |
20 changes: 20 additions & 0 deletions
20
docs/src/examples/components/Header/Variations/HeaderExampleColor.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react' | ||
import _ from 'lodash' | ||
import { Header, ProviderConsumer } from '@stardust-ui/react' | ||
|
||
const HeaderExampleColor = () => ( | ||
<ProviderConsumer | ||
render={({ siteVariables: { emphasisColors, naturalColors } }) => | ||
_.keys({ ...emphasisColors, ...naturalColors }).map(color => ( | ||
<Header key={color} as="h4" color={color}> | ||
{_.startCase(color)} | ||
<Header.Description color={color}> | ||
{`Description of ${_.lowerCase(color)} color`} | ||
</Header.Description> | ||
</Header> | ||
)) | ||
} | ||
/> | ||
) | ||
|
||
export default HeaderExampleColor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 10 additions & 4 deletions
14
src/themes/teams/components/Header/headerDescriptionStyles.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
import * as _ from 'lodash' | ||
|
||
import { pxToRem } from '../../utils' | ||
import { ICSSInJSStyle } from '../../../types' | ||
import { ICSSInJSStyle, ComponentSlotStylesInput } from '../../../types' | ||
import { HeaderDescriptionProps } from '../../../../components/Header/HeaderDescription' | ||
import { HeaderDescriptionVariables } from './headerDescriptionVariables' | ||
|
||
export default { | ||
root: ({ variables: v }): ICSSInJSStyle => ({ | ||
const headerStyles: ComponentSlotStylesInput<HeaderDescriptionProps, HeaderDescriptionVariables> = { | ||
root: ({ props: p, variables: v }): ICSSInJSStyle => ({ | ||
display: 'block', | ||
color: _.get(v.colors, p.color, v.color), | ||
fontSize: pxToRem(22), | ||
color: v.color, | ||
fontWeight: 400, | ||
}), | ||
} | ||
|
||
export default headerStyles |
18 changes: 15 additions & 3 deletions
18
src/themes/teams/components/Header/headerDescriptionVariables.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
export default siteVariables => ({ | ||
color: siteVariables.gray04, | ||
}) | ||
import { ColorValues } from '../../../types' | ||
import { mapColorsToScheme } from '../../../../lib' | ||
|
||
export interface HeaderDescriptionVariables { | ||
colors: ColorValues<string> | ||
color: string | ||
} | ||
|
||
export default (siteVariables: any): HeaderDescriptionVariables => { | ||
const colorVariant = 500 | ||
return { | ||
colors: mapColorsToScheme(siteVariables, colorVariant), | ||
color: siteVariables.gray04, | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
import { ICSSInJSStyle } from '../../../types' | ||
import * as _ from 'lodash' | ||
import { TextAlignProperty } from 'csstype' | ||
|
||
export default { | ||
root: ({ props, variables: v }): ICSSInJSStyle => ({ | ||
color: v.color, | ||
textAlign: props.textAlign, | ||
import { ICSSInJSStyle, ComponentSlotStylesInput } from '../../../types' | ||
import { HeaderProps } from '../../../../components/Header/Header' | ||
import { HeaderVariables } from './headerVariables' | ||
|
||
const headerStyles: ComponentSlotStylesInput<HeaderProps, HeaderVariables> = { | ||
root: ({ props: p, variables: v }): ICSSInJSStyle => ({ | ||
display: 'block', | ||
...(props.description && { marginBottom: 0 }), | ||
color: _.get(v.colors, p.color, v.color), | ||
textAlign: p.textAlign as TextAlignProperty, | ||
...(p.description && { marginBottom: 0 }), | ||
}), | ||
} | ||
|
||
export default headerStyles |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what we can do there, but this line looks very confusing 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed, but not sure what we can do either.. 😢