Skip to content

Commit

Permalink
Merge pull request #77 from Altalogy/launchpad/feature/text-component
Browse files Browse the repository at this point in the history
feat(primitive): add text component
  • Loading branch information
corquaid authored Apr 21, 2022
2 parents 484614b + bf1ebe6 commit 675526f
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 10 deletions.
4 changes: 2 additions & 2 deletions applications/launchpad_v2/src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { act, render } from '@testing-library/react'
import { render } from '@testing-library/react'
import { randomFillSync } from 'crypto'
import { mockIPC, clearMocks } from '@tauri-apps/api/mocks'
import { clearMocks } from '@tauri-apps/api/mocks'
import { ThemeProvider } from 'styled-components'

import App from './App'
Expand Down
4 changes: 0 additions & 4 deletions applications/launchpad_v2/src/assets/fonts/fonts.ts

This file was deleted.

33 changes: 33 additions & 0 deletions applications/launchpad_v2/src/components/Text/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { StyledText } from './styles'
import { TextProps } from './types'
import styles from '../../styles/styles'

/**
* @name Text
*
* @typedef TextProps
* @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
*
* @example
* <Text type='defaultMedium' color={styles.colors.dark.primary}>...text goes here...</Text>
*/

const Text = ({
type = 'defaultMedium',
color,
children,
}: TextProps) => {
const textStyles = {
color: color,
...styles.typography[type]
}
return (
<>
<StyledText style={textStyles}>{children}</StyledText>
</>
)
}

export default Text
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``
27 changes: 27 additions & 0 deletions applications/launchpad_v2/src/components/Text/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { ReactNode } from 'react'

/**
* @typedef TextProps
* @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?:
| 'header'
| 'subheader'
| 'defaultHeavy'
| 'defaultMedium'
| 'defaultUnder'
| 'smallHeavy'
| 'smallMedium'
| 'smallUnder'
| 'microHeavy'
| 'microRegular'
| 'microOblique'
children: ReactNode
color?: string
}


Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fireEvent, render, screen } from '@testing-library/react'
import { render, screen } from '@testing-library/react'
import { Provider } from 'react-redux'
import { randomFillSync } from 'crypto'
import { mockIPC, clearMocks } from '@tauri-apps/api/mocks'
Expand Down
4 changes: 3 additions & 1 deletion applications/launchpad_v2/src/custom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ declare module '*.svg' {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const content: any
export default content
}
}

declare module '*.otf'
1 change: 0 additions & 1 deletion applications/launchpad_v2/src/fonts.d.ts

This file was deleted.

15 changes: 15 additions & 0 deletions applications/launchpad_v2/src/styles/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,18 @@ div#root {
overflow: hidden;
background: transparent;
}

@font-face {
src: url('../assets/fonts/AvenirLTStd-Book.otf');
font-family: 'AvenirRegular'
}

@font-face {
src: url('../assets/fonts/AvenirLTStd-Medium.otf');
font-family: 'AvenirMedium'
}

@font-face {
src: url('../assets/fonts/AvenirLTStd-Heavy.otf');
font-family: 'AvenirHeavy'
}
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 675526f

Please sign in to comment.