1.0.2 • Published 1 year ago

nginformatica-styleguide v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

A repository to center and document, initially, the colors of the NGInformatica Apps.

:package: Install

The package still in alpha

$ npm i nginformatica-styleguide

or

$ yarn add nginformatica-styleguide

:books: 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 'nginformatica-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 nginformatica theme in the default theme of styled-components

issue

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

import { theme } from 'nginformatica-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", ...]
    },
    ...
}
1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.0.1-alpha.5

2 years ago

0.0.1-alpha.3

2 years ago

0.0.1-alpha.2

2 years ago

0.0.1-alpha.1

2 years ago