Skip to content
ํ”„๋กœ์ ํŠธ

์†Œ๊ฐœ

๐Ÿš—๐Ÿ’จ AutoGuru's design system

๋””์ž์ธ ๋ฐ ๋ฏธ๋””์–ด

์ด ์ˆ˜์น˜๋ฅผ ์ธก์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•

์ธก์ •๋œ ์Šคํƒ€ ์ฆ๊ฐ€

in 24h
0
in 7 days
๊ธฐ๋ก ์ˆ˜์ง‘ ์ค‘
in 15 days
๊ธฐ๋ก ์ˆ˜์ง‘ ์ค‘
in 1 month
๊ธฐ๋ก ์ˆ˜์ง‘ ์ค‘

์„œ๋กœ ๊ฒน์น˜๋Š” ๊ธฐ๊ฐ„์˜ ์ˆœ์ฆ๊ฐ€๋Ÿ‰์ด๋ฉฐ ์ผ๋ณ„ ํ•ฉ๊ณ„๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค. ์ธก์ •๊ฐ’์ด ์—†์œผ๋ฉด ๋น„์›Œ ๋‘ก๋‹ˆ๋‹ค. ์Šคํƒ€๋Š” ๊ด€์‹ฌ๋„๋ฅผ ๋‚˜ํƒ€๋‚ด๋ฉฐ ํ’ˆ์งˆ์„ ๋ณด์žฅํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

README.md

Original

@autoguru/overdrive


Overdrive

Overdrive is a product component library, and design system for AutoGuru. Built with React, TypeScript, Vanilla Extract, and Storybook.

The components are housed in Storybook which provides interactive documentation, UI playground, and interaction testing.

Storybook

Visit the Overdrive Storybook site too access foundations, components and API specifications:

overdrive.autoguru.io

Usage

To use Overdrive in your project, install it with Bun:

bun add @autoguru/overdrive react react-dom

Then, import the reset and configure the Overdrive Provider with the theme you want to use:

import { OverdriveProvider, Button } from '@autoguru/overdrive';

<OverdriveProvider>
  <Button variant="primary">Hello World</Button>
</OverdriveProvider>;

The Overdrive Provider automatically applies global base styles to the body tag. If you need more control over where the global base styles are applied, you can also apply data-od-base to any element.

You can also customise the theme colours using the provider props:

<OverdriveProvider
  theme={baseTheme}
  colorOverrides={{
    primaryBackground: '#FF0000',
    primaryForeground: '#FFFFFF',
    primaryBackgroundMild: '#FFE5E5',
    primaryBackgroundStrong: '#CC0000',
    primaryBorder: '#CC0000',
  }}
>
  <Button variant="primary">Custom Red Theme</Button>
</OverdriveProvider>

Lite provider

OverdriveLiteProvider is a lighter OverdriveProvider for apps whose colours are fixed when they are built. It supplies the same contexts, theme class and markup, so components render identically under it, but it does not import the theme's token values or the colour library behind colorOverrides: theme colours come from the CSS variables the theme already ships. In a minimal app that saves about 8 kB of gzipped JavaScript on first load.

import { OverdriveLiteProvider } from '@autoguru/overdrive/components/OverdriveLiteProvider';
import { Button } from '@autoguru/overdrive/components/Button';

<OverdriveLiteProvider>
  <Button variant="primary">Hello World</Button>
</OverdriveLiteProvider>;
  • Use it when the app has no brand colours, or knows them when it is built. Keep OverdriveProvider when brand colours arrive at runtime, for example per tenant from an API.

  • It takes the same theme, breakpoints, locale, portalMountPoint and noBodyLevelTheming props. In place of colorOverrides it takes colorOverrideStyles, the output of makeColorOverrideStyles.

  • Run makeColorOverrideStyles at build time or on the server, not in the browser, or the colour library comes back. In a vanilla-extract .css.ts file, import it from @autoguru/overdrive/themes/colorOverrides: a style file pulls in the CSS of everything it imports, and through the main entry that is every component.

    // brand.css.ts
    import { makeColorOverrideStyles } from '@autoguru/overdrive/themes/colorOverrides';
    
    export const brandStyles = makeColorOverrideStyles({
      primaryBackground: '#6d39a8',
    });
    
    <OverdriveLiteProvider colorOverrideStyles={brandStyles}>
    

    On a theme other than the base theme, pass that theme's tokens as the second argument, so contrast is worked out against its own surfaces. Outside a browser it can't check that a colour is valid, so pass valid CSS colours: an invalid one is passed through, where OverdriveProvider in the browser would drop it with a warning.

  • The saving needs your bundler to leave the full provider out. Vite and Rollup do so from the main entry, though from the uncompiled main entry its theme exports still bring in the base colour palette (about 1 kB gzipped); elsewhere, or to leave that out too, import from deep paths such as components/OverdriveLiteProvider. Importing OverdriveProvider or ThemeOverrideDebugger anywhere in the app brings the colour code back. Importing a theme's index or useDocumentBodyStyles brings back token values.

  • To use another theme without its token values, pass only what the provider reads: { name, themeRef, vars }, with themeRef from the theme's theme.css (for example flatRedThemeClass) and vars set to overdriveTokens from themes/theme.css. Define that object once, outside any component, so it isn't a new theme on every render.

  • useTheme().colorOverrides is always undefined under it, so ThemeOverrideDebugger reports the theme's own colours, not a brand passed as colorOverrideStyles.

Precompiled CSS entry

@autoguru/overdrive ships vanilla-extract style files that compile in your bundler, so it needs the vanilla-extract plugin for webpack, Vite or Next. If your bundler or test runner has no such plugin (Bun, bun test, Rolldown, rspack, esbuild), import from @autoguru/overdrive/compiled instead. Its styles were compiled when Overdrive was built: the JavaScript only holds class names, and the CSS is in plain stylesheets you import once at the root of your app. Rolldown 1.x no longer bundles CSS, so with plain Rolldown load styles.css outside the bundle, with a <link> or a copy step.

import '@autoguru/overdrive/compiled/reset.css'; // optional, as styles/global/reset.css
import '@autoguru/overdrive/compiled/fonts.css'; // optional, as styles/global/fonts.css
import '@autoguru/overdrive/compiled/styles.css';

import { OverdriveProvider, Button } from '@autoguru/overdrive/compiled';
import { flatRedTheme } from '@autoguru/overdrive/compiled/themes';

<OverdriveProvider theme={flatRedTheme}>
  <Button variant="primary">Hello World</Button>
</OverdriveProvider>;
  • @autoguru/overdrive/compiled has the same exports and types as @autoguru/overdrive. Themes are on @autoguru/overdrive/compiled/themes.
  • A few public exports are not on the main entry, only on deep imports. Their compiled versions are on @autoguru/overdrive/compiled/components (adds DataTable and ModalFooter), @autoguru/overdrive/compiled/styles (adds darkSurface and LAYER_ORDER) and @autoguru/overdrive/compiled/utils (adds the utils index, such as isBrowser, mergeRefs and setRef).
  • Other deep imports, such as components/*, styles/*, themes/*, hooks or utils/*, are not compiled. Most of their names are also on @autoguru/overdrive/compiled or one of the subpaths above, so import them from there. Names only on other deep paths have no compiled version, for example HintText, Popover, PopoverTrigger, EAlignment, useRadioContext, dataAttrs, the themes/makeTheme breakpoint helpers and the utils/dateFormat and utils/number helpers. Vanilla-extract authoring helpers, such as responsiveStyle, focusOutline, the layer names and the sprinkles internals, need a vanilla-extract plugin by nature.
  • styles.css holds every component, theme and token rule, ordered by the same CSS cascade layers. The od- token variables and colorOverrides work as they do on the main entry.
  • Nothing touches window or document at import, so it renders on the server.
  • Pick one entry per app. Class names differ between the two, so loading both ships about 316 KB of CSS twice, and both define the global :root tokens.
  • Each entry has its own React contexts. Every React tree needs an OverdriveProvider from the same entry as its components; a component under the other entry's provider throws "You haven't used an <OverdriveProvider>".
  • If you embed compiled components beside a host that uses the main entry, consider noBodyLevelTheming on your provider, so the two providers don't both set the theme class on document.body.

Thanks

Chromatic for providing visual regression testing.

License

MIT ยฉAutoGuru

AutoGuru

๊ด€๋ จ ํ”„๋กœ์ ํŠธ ์‚ดํŽด๋ณด๊ธฐ

๋ถˆ๋Ÿฌ์˜ค๋Š” ์ค‘โ€ฆ