@salty-css/eslint-plugin-core
TypeScript icon, indicating that this package has built-in type declarations

0.0.1-alpha.12 • Public • Published

Salty Css

Basic usage example with Button

Initial requirements

  1. Add saltyPlugin to vite or webpack config from @salty-css/vite or @salty-css/webpack
  2. Create salty-config.ts to the root of your project
  3. Import global styles to any regular .css file from saltygen/index.css (does not exist during first run, cli command coming later)
  4. Create salty components with styled only inside files that end with .css.ts, .salty.ts .styled.ts or .styles.ts

Code examples

Salty config

import { defineConfig } from '@salty-css/core/config';

export const config = defineConfig({
  variables: {
    colors: {
      brand: '#111',
      highlight: 'yellow',
    },
  },
  global: {
    html: {
      backgroundColor: '#f8f8f8',
    },
  },
});

Your React component file

import { Wrapper } from '../components/wrapper/wrapper.css';
import { Button } from '../components/button/button.css';

export const IndexPage = () => {
  return (
    <Wrapper>
      <Button variant="solid" onClick={() => alert('It is a button.')}>
        Outlined
      </Button>
    </Wrapper>
  );
};

Wrapper (components/wrapper/wrapper.css.ts)

import { styled } from '@salty-css/react/styled';

export const Wrapper = styled('div', {
  base: {
    display: 'block',
    padding: '2vw',
  },
});

Button (components/button/button.css.ts)

import { styled } from '@salty-css/react/styled';

export const Button = styled('button', {
  base: {
    display: 'block',
    padding: `0.6em 1.2em`,
    border: '1px solid currentColor',
    background: 'transparent',
    color: 'currentColor/40',
    cursor: 'pointer',
    transition: '200ms',
    textDecoration: 'none',
    '&:hover': {
      background: 'black',
      borderColor: 'black',
      color: 'white',
    },
    '&:disabled': {
      opacity: 0.25,
      pointerEvents: 'none',
    },
  },
  variants: {
    variant: {
      outlined: {
        // same as default styles
      },
      solid: {
        '&:not(:hover)': {
          background: 'black',
          borderColor: 'black',
          color: 'white',
        },
        '&:hover': {
          background: 'transparent',
          borderColor: 'currentColor',
          color: 'currentColor',
        },
      },
    },
  },
});

More examples coming soon

Readme

Keywords

none

Package Sidebar

Install

npm i @salty-css/eslint-plugin-core

Weekly Downloads

47

Version

0.0.1-alpha.12

License

MIT

Unpacked Size

6.59 kB

Total Files

6

Last publish

Collaborators

  • tremppu