Skip to content

Commit

Permalink
refactor: move globalStyles, set default Text type
Browse files Browse the repository at this point in the history
  • Loading branch information
corquaid authored and tarnas14 committed May 4, 2022
1 parent 5acafa1 commit c572ada
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 28 deletions.
28 changes: 3 additions & 25 deletions applications/launchpad_v2/src/components/Text/index.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,7 @@
import { createGlobalStyle } from 'styled-components'

import { AvenirRegular, AvenirMedium, AvenirHeavy } from '../../assets/fonts/fonts'

import { StyledText } from './styles'
import { TextProps } from './types'

import styles from '../../styles/styles'

/**
* Global style rule to make fonts files accessible
*/
const GlobalFonts = createGlobalStyle`
@font-face {
src: url(${AvenirRegular});
font-family: 'AvenirRegular'
}
@font-face {
src: url(${AvenirMedium});
font-family: 'AvenirMedium'
}
@font-face {
src: url(${AvenirHeavy});
font-family: 'AvenirHeavy'
}
`
/**
* @name Text
*
Expand All @@ -36,7 +15,7 @@ const GlobalFonts = createGlobalStyle`
*/

const Text = ({
type,
type = 'defaultMedium',
color,
children,
}: TextProps) => {
Expand All @@ -46,8 +25,7 @@ const Text = ({
}
return (
<>
<GlobalFonts />
<p style={textStyles}>{children}</p>
<StyledText style={textStyles}>{children}</StyledText>
</>
)
}
Expand Down
3 changes: 3 additions & 0 deletions applications/launchpad_v2/src/components/Text/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import styled from 'styled-components'

export const StyledText = styled.p``
4 changes: 2 additions & 2 deletions applications/launchpad_v2/src/components/Text/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { ReactNode } from 'react'

/**
* @typedef TextProps
* @prop {'header' | 'subheader' | 'defaultHeavy' | 'defaultMedium' | 'defaultUnder' | 'smallHeavy' | 'smallMedium' | 'smallUnder' | 'microHeavy' | 'microRegular' | 'microOblique' } type - text styles
* @prop {'header' | 'subheader' | 'defaultHeavy' | 'defaultMedium' | 'defaultUnder' | 'smallHeavy' | 'smallMedium' | 'smallUnder' | 'microHeavy' | 'microRegular' | 'microOblique' } [type] - text styles
* @prop {ReactNode} children - text content to display
* @prop {string} [color] - font color
*/

export interface TextProps {
type:
type?:
| 'header'
| 'subheader'
| 'defaultHeavy'
Expand Down
24 changes: 24 additions & 0 deletions applications/launchpad_v2/src/styles/globalStyles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { createGlobalStyle } from 'styled-components'

import { AvenirRegular, AvenirMedium, AvenirHeavy } from '../assets/fonts/fonts'

/**
* Global styles
*/

const GlobalStyle = createGlobalStyle`
@font-face {
src: url(${AvenirRegular});
font-family: 'AvenirRegular'
}
@font-face {
src: url(${AvenirMedium});
font-family: 'AvenirMedium'
}
@font-face {
src: url(${AvenirHeavy});
font-family: 'AvenirHeavy'
}
`

export default GlobalStyle
2 changes: 1 addition & 1 deletion applications/launchpad_v2/src/styles/styles/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import colors from './colors'
import gradients from './gradients'
import typography from '../typography'
import typography from './typography'

const styles = {
colors,
Expand Down

0 comments on commit c572ada

Please sign in to comment.