-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds pallette grid to color pallette guidelines
- Loading branch information
Showing
2 changed files
with
219 additions
and
32 deletions.
There are no files selected for viewing
This file contains 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 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,63 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { sortBy } from 'lodash'; | ||
import TabNav, { TabNavItem } from '../../../../components/tab-nav/tab-nav'; | ||
|
||
/** | ||
* Given `/components/button/react/`, this function returns `react`. | ||
*/ | ||
const getPlatformSlugByPath = path => { | ||
const arr = path.split('/'); | ||
return arr[arr.length - 2]; | ||
}; | ||
|
||
const sortPlatforms = ({ node }) => { | ||
const platformOrder = { | ||
usage: 1, | ||
react: 2, | ||
scss: 3, | ||
ios: 4, | ||
swiftui: 5, | ||
android: 6, | ||
}; | ||
|
||
const { path } = node; | ||
return platformOrder[getPlatformSlugByPath(path)]; | ||
}; | ||
|
||
/** | ||
* Given `/components/button/react/`, this function returns `React`. | ||
*/ | ||
const getPlatformDisplayName = path => { | ||
const displayName = { | ||
neutral: 'Neutral', | ||
primary: 'Primary & info', | ||
success: 'Success, finance & ratings', | ||
guidance: 'Guidance & visualization', | ||
alert: 'Alert', | ||
caution: 'Caution', | ||
accent: 'Accents', | ||
}; | ||
|
||
return displayName[getPlatformSlugByPath(path)]; | ||
}; | ||
|
||
const PlatformNav = ({ platformNavQueryResults }) => { | ||
const sortedPlatforms = sortBy(platformNavQueryResults.edges, sortPlatforms); | ||
|
||
return ( | ||
<TabNav> | ||
{sortedPlatforms.map(({ node }) => ( | ||
<TabNavItem to={node.path} key={node.path}> | ||
{getPlatformDisplayName(node.path)} | ||
</TabNavItem> | ||
))} | ||
</TabNav> | ||
); | ||
}; | ||
|
||
PlatformNav.propTypes = { | ||
platformNavQueryResults: PropTypes.shape({}).isRequired, | ||
}; | ||
|
||
export default PlatformNav; |