@keepfy/styleguide
TypeScript icon, indicating that this package has built-in type declarations

0.0.1-alpha.3 • Public • Published
KEEPFY

STYLEGUIDE

A repository to center and document, initially, the colors of the Keepfy App.

📦 Install

The package still in alpha

$ npm i @keepfy/styleguide

or

$ yarn add @keepfy/styleguide

📚 Usage

The work in progress of the colors documentation is here

styled-components + typescript

Using the ThemeProvider of styled-components, the theme property will be injected into all styled-components below of it.

import { theme } from '@keepfy/styleguide'
import styled, { ThemeProvider as StyledThemeProvider } from 'styled-components'

type Kind = 'critical' | 'medium' | 'high' | 'minimal' | 'low' | 'neutral'

interface IProps {
    kind: Kind
    children?: React.ReactNode
}

const CardStyled = styled('div')<IProps>(
    ({ theme, kind }) => ({
        padding: '0.5rem',
        borderLeft: `4px solid ${ theme.colors.priority[kind].main}`,
        backgroundColor: theme.colors.priority[kind].light,
        width: '144px',
        height: '80px',
        margin: '0 1rem 1rem 0',
        borderRadius: '4px',
        position: 'relative'
    })
)

const App = () => (
    <StyledThemeProvider theme={ theme }>
        <CardStyled kind="critical" />
    </StyledThemeProvider>
)

For auto-types of the theme inside of styled components:

Extend the keepfy theme in the default theme of styled-components

issue

// eg.: src/types/styled.ts

import { theme } from '@keepfy/styleguide'

type Theme = typeof theme

declare module 'styled-components' {
  export interface DefaultTheme extends Theme {}
}

Don't forget to add it to the typeRoots in tsconfig.json

Eg.: in tsconfig.json

{
    "compilerOptions": {
	...,
+	"typeRoots": ["./node_modules/@types/", "./src/types/styled.ts", ...]
    },
    ...
}

Readme

Keywords

none

Package Sidebar

Install

npm i @keepfy/styleguide

Weekly Downloads

1

Version

0.0.1-alpha.3

License

MIT

Unpacked Size

25 kB

Total Files

13

Last publish

Collaborators

  • ti-nginformatica
  • leonardo.rigon
  • jeovazero
  • jacksjm