Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(primitive): add text component #77

Merged
merged 6 commits into from
Apr 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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