Skip to content

Commit

Permalink
chore(Tokens): Export individual tokens (#3803)
Browse files Browse the repository at this point in the history
  • Loading branch information
markhigham authored May 17, 2024
1 parent 88407bf commit 1a8b129
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 23 deletions.
28 changes: 27 additions & 1 deletion packages/design-tokens/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,35 @@
import selectors from './selectors'

export * from './types'
export * from './flat'

export { getTheme } from './getters'

export { default as selectors } from './selectors'
export { selectors }

export { default as lightTheme } from './themes/light'
export { default as darkTheme } from './themes/dark'

const {
animation,
breakpoint,
color,
fontSize,
mediaQuery,
mq,
shadow,
spacing,
zIndex,
} = selectors

export {
animation,
breakpoint,
color,
fontSize,
mediaQuery,
mq,
shadow,
spacing,
zIndex,
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { ColorGroup, selectors } from '@royalnavy/design-tokens'
import { color, ColorGroup } from '@royalnavy/design-tokens'

import {
StyledDescription,
Expand All @@ -10,8 +10,6 @@ import {
} from './partials'
import { getColorDescription, getColors } from './utils'

const { color } = selectors

type PaletteProps = {
group: ColorGroup
}
Expand Down
8 changes: 2 additions & 6 deletions packages/react-component-library/src/tokens/ElevatedPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'

import { selectors } from '@royalnavy/design-tokens'
import { shadow, spacing } from '@royalnavy/design-tokens'

import styled from 'styled-components'

Expand All @@ -13,8 +13,6 @@ import {
} from './partials'
import { getShadowDescription, getShadows } from './utils'

const { shadow, spacing } = selectors

const StyledContainer = styled.div`
padding-bottom: ${spacing('13')};
`
Expand Down Expand Up @@ -44,9 +42,7 @@ export const ElevationTable = () => {
export const UsageText = `
import styled from 'styled-components'
import { selectors } from '@royalnavy/design-tokens'
const { shadow } = selectors
import { shadow } from '@royalnavy/design-tokens'
export const StyledPanel = styled.div\`
box-shadow: \${ shadow('1') })};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React from 'react'
import styled from 'styled-components'
import { selectors } from '@royalnavy/design-tokens'

const { spacing, fontSize, color } = selectors
import { spacing, fontSize, color } from '@royalnavy/design-tokens'

const StyledSwatch = styled.span<{ $backgroundColor: string }>`
background-color: ${({ $backgroundColor }) => $backgroundColor ?? 'none'};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import React from 'react'
import { selectors } from '@royalnavy/design-tokens'
import { fontSize, color, spacing } from '@royalnavy/design-tokens'
import styled from 'styled-components'
import { getTypographySizes } from './utils'

const { fontSize, color, spacing } = selectors

const tokens = getTypographySizes()

const StyledRow = styled.div`
Expand Down
3 changes: 1 addition & 2 deletions packages/react-component-library/src/tokens/colors.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ categorisation and data visualisation, but they don’t have any state associate
---

## Usage
<Source dark code={`import { selectors } from '@royalnavy/design-tokens'
const { color } = selectors
<Source dark code={`import { color } from '@royalnavy/design-tokens'
<div style={{ backgroundColor: color('action', '400') }}>
Hello colo(u)rful World!
Expand Down
3 changes: 1 addition & 2 deletions packages/react-component-library/src/tokens/spacing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ The Spacing Scale values, much like the Typography Scale values, doesn't increas
## Usage

<Source dark code={`# Typescript usage of spacing
import { selectors } from '@royalnavy/design-tokens'
import { spacing } from '@royalnavy/design-tokens'
const { spacing } = selectors
export const ExampleComponent = () => {
/* This is a contrived example to show individual usage
Expand Down
4 changes: 1 addition & 3 deletions packages/react-component-library/src/tokens/typography.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ sans-serif;

## Usage

<Source dark code={`import { selectors } from '@royalnavy/design-tokens'
const { fontSize } = selectors
<Source dark code={`import { fontSize } from '@royalnavy/design-tokens'
<p style={{ fontSize: fontSize('xl') }}>
A contrived example of using fontSize
Expand Down

0 comments on commit 1a8b129

Please sign in to comment.