0.3.2 • Published 7 months ago

@dxos/aurora v0.3.2

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

DXOS Aurora

This readme is to be rewritten.

The docs below are for this package’s predecessor.


The react-components package is the single source of truth for DXOS’s lower-level design system.

To get started, you’ll need to set up how you’ll build with this package, add peer dependencies, set up the provider, and set up theming.

Set up the build…

…with Vite

Using the design system requires opting-in in a few places, but by design it otherwise needs no configuration.

1. Add the Vite plugin

Add @dxos/react-components to the project’s dev dependencies, then extend the project’s Vite config (vite.config.ts) to use it, e.g.:

// ...
import { ThemePlugin } from '@dxos/aurora-theme/plugin';
// ...
export default defineConfig({
  // ...
  plugins: [
    // ...
    ThemePlugin({content: [
        resolve(__dirname, '../node_modules/@dxos/aurora/dist/**/*.mjs'),
resolve(__dirname, '../node_modules/@dxos/aurora-theme/dist/**/*.mjs'),
        './index.html', './src/**/*.{js,ts,jsx,tsx}'
      ]}),
    // ...
  ]
  // ...
});
// ...

Ensure content contains globs for your project’s own files that will use Tailwind classnames, as well as any DXOS design system packages your project uses, e.g.:

'./node_modules/@dxos/react-components/dist/**/*.mjs',
'./node_modules/@dxos/react-appkit/dist/**/*.mjs',
'./node_modules/@dxos/aurora-composer/dist/**/*.mjs',

2. Reference the basic stylesheet

In the file which calls React DOM’s createRoot or render, add:

import '@dxosTheme';

…with ESBuild

The ESBuild plugin is experimental and has several caveats noted below, proceed with caution.

1. Add the ESBuild plugin

Add @dxos/react-components to the project’s dev dependencies, then extend the project’s ESBuild config to use it, e.g.:

// ...
import { ThemePlugins } from '@dxos/react-components/esbuild-plugin';
// ...
void build({
  entryPoints: [/* ... */, resolve(__dirname, '../node_modules/@dxos/react-components/src/theme.css')],
  // ...
  plugins: ThemePlugins({
    outdir: resolve(__dirname, '../dist'),
    content: [
      resolve(__dirname, '../index.html'),
      resolve(__dirname, '../src/**/*.{js,ts,jsx,tsx}'),
      resolve(__dirname, '../node_modules/@dxos/aurora/dist/**/*.mjs'),
resolve(__dirname, '../node_modules/@dxos/aurora-theme/dist/**/*.mjs')
      // other sources to scan
    ]
  })
});
// ...

Ensure theme.css from react-components is included as an entrypoint, and outdir passed to ThemePlugins is the same as provided to ESBuild.

2. Reference the basic stylesheet

Load the built stylesheet as appropriate for your project, e.g. simply add it to index.html:

<link rel="stylesheet" href="./dist/node_modules/@dxos/react-components/src/theme.css"/>

Note that this is not in your project’s node_modules directory, it’s in your project’s outdir.

…with your own build stack

This package exports both CJS and ESM builds of its components, though these are styled with Tailwind as the design token system. Any build stack can use the component builds in this package, you’ll just need to configure your build to handle Tailwind so that styles are applied correctly.

Follow the Tailwind Framework Guides documentation relevant to your stack to see how that’s done, but make the following modifications:

  • Use the Tailwind configuration from this package:
import tailwindcss from 'tailwindcss';
import { tailwindConfig } from '@dxos/react-components';
// ...
tailwindcss(
  tailwindConfig({
    content: [/* Wherever else Tailwind utility classes are used */],
    /* Optional params as neeeded */
  })
)
// ...
  • Instead of adding the Tailwind directives to your own CSS, use or import this package’s theme.css (react-components/dist/plugin/theme.css) which adds the Tailwind directives itself.
  • This package relies on font assets installed via npm as dependencies; if you’re seeing errors in the browser console or build logs about missing .woff2 files, ensure your build can correctly resolve the import directives used in theme.css e.g. @import '@fontsource/roboto-flex/variable-full.css'.

If you have any issues integrating this package with your build, please file an issue including details about your build stack and what result you’re getting.

Add peer dependencies

This package uses icons from phosphor-icons, but lists them as a peer dependency to avoid re-exporting that package; use your project’s package manager to add phosphor-icons as a dependency.

Set up the provider

In order for the project to render correctly, wrap your app with <ThemeProvider/>.

Set up theming

In order to display the correct theme, you need to mark <html> with the correct class from the <head> tag, otherwise it will flash the wrong theme:

<head>
  <script>
    if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
      document.documentElement.classList.add('dark')
    } else {
      document.documentElement.classList.remove('dark')
    }
  </script>
</head>

If you want to keep up with prefers-color-scheme, add:

window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', function(e){ if(e.matches){
  document.documentElement.classList.add('dark')
} else {
  document.documentElement.classList.remove('dark')
}})

You could combine the two with a script like this one:

function setTheme(darkMode) {
  document.documentElement.classList[darkMode ? 'add' : 'remove']('dark')
}
setTheme(window.matchMedia('(prefers-color-scheme: dark)').matches)
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', function (e) {
  setTheme(e.matches)
});

You can augment this predicate checking any preferences saved in localStorage, etc.

Note that you can apply this classname selectively further down the DOM tree if needed.

0.1.53-main.d0f911b

10 months ago

0.1.53-main.14243d1

10 months ago

0.1.53-main.797c2c4

10 months ago

0.1.52-main.0e90c21

10 months ago

0.3.2-main.220594a

7 months ago

0.3.1-main.b9bb100

7 months ago

0.3.2-main.59eafc5

7 months ago

0.1.53-main.db41187

10 months ago

0.1.53-main.d535786

10 months ago

0.1.51-main.acb2ded

10 months ago

0.1.51-main.04cd027

10 months ago

0.3.2-main.b6e958d

7 months ago

0.2.1-main.864bb49

7 months ago

0.1.52-main.86cce18

10 months ago

0.1.53-main.706990e

10 months ago

0.2.4-next.22eeb4f

7 months ago

0.1.53-main.b6f5d87

10 months ago

0.1.53-main.4544117

10 months ago

0.1.52-main.222c456

10 months ago

0.1.53-main.123f460

10 months ago

0.3.1-main.5e68e9d

7 months ago

0.3.2-main.48c28c7

7 months ago

0.1.52-main.6111d78

10 months ago

0.1.53-main.09c4c35

10 months ago

0.2.1-main.cba49f4

8 months ago

0.3.1-main.8e630ac

7 months ago

0.1.51-main.451963a

10 months ago

0.2.1-main.276b300

8 months ago

0.2.4-main.22eeb4f

7 months ago

0.2.1-main.310641e

8 months ago

0.3.2-main.c536b5f

7 months ago

0.3.2-main.710bb14

7 months ago

0.2.2-main.060c13d

7 months ago

0.1.51-main.5787f10

10 months ago

0.1.53-main.603ff3b

10 months ago

0.1.51-main.5c57788

10 months ago

0.1.51-main.0e88376

10 months ago

0.1.53-main.038926e

10 months ago

0.1.53-main.d2dd40b

10 months ago

0.3.2-main.774ebb6

7 months ago

0.2.2-main.c9a018f

7 months ago

0.3.1-main.0fddbd4

7 months ago

0.3.2-main.ce2190e

7 months ago

0.2.4-main.f0c8b8e

7 months ago

0.3.2-main.4291678

7 months ago

0.1.51-next.5787f10

10 months ago

0.1.53-main.9fb5fd8

10 months ago

0.1.51-next.be0b180

10 months ago

0.2.4-main.e68de56

7 months ago

0.2.1-main.60390aa

7 months ago

0.3.2-main.f938553

7 months ago

0.1.51-main.be0b180

10 months ago

0.3.2-main.d77d2bc

7 months ago

0.2.1-main.c0cd511

7 months ago

0.3.2-main.648180e

7 months ago

0.3.2-next.46a9f6a

7 months ago

0.1.51-next.57ad9f3

10 months ago

0.1.51-main.04d9478

10 months ago

0.3.1-main.2d5b138

7 months ago

0.2.4-main.cc5efc5

7 months ago

0.1.53-main.acf3e0d

10 months ago

0.1.53-main.b051972

10 months ago

0.1.51-main.03aa1a8

10 months ago

0.2.1-main.90be47b

7 months ago

0.3.1-next.6fd382b

7 months ago

0.3.2-main.14bd43d

7 months ago

0.3.1-main.3c1c830

7 months ago

0.2.1-main.f822bf6

7 months ago

0.1.52-main.37e82de

10 months ago

0.1.51-main.b9e09c2

10 months ago

0.3.2-main.85a9e4b

7 months ago

0.1.51-next.2bb4663

10 months ago

0.3.2-main.9928d98

7 months ago

0.2.2-main.1800537

7 months ago

0.3.2-main.3d933cf

7 months ago

0.2.2-main.450a215

7 months ago

0.3.2-main.e5374ab

7 months ago

0.1.53-main.af8f93b

10 months ago

0.3.2-main.4a1f4da

7 months ago

0.1.51-main.474a069

10 months ago

0.2.3-next.2d1ef8a

7 months ago

0.3.2-main.bc9cb77

7 months ago

0.1.52-main.e73bc9f

10 months ago

0.1.53-main.55faa2f

10 months ago

0.1.53-main.602887f

10 months ago

0.1.52-main.9577e70

10 months ago

0.3.2-main.428886c

7 months ago

0.3.1-main.6ca5432

7 months ago

0.1.53-main.3ecc504

10 months ago

0.3.2-main.fa875a7

7 months ago

0.1.53-main.6e28045

10 months ago

0.3.2-main.5292d27

7 months ago

0.1.51-main.79a11ce

10 months ago

0.2.1-main.b4cb4d5

7 months ago

0.3.2-main.05033b7

7 months ago

0.3.2-main.224d3c3

7 months ago

0.3.1-main.d8f3335

7 months ago

0.1.53-main.a67c9cf

10 months ago

0.3.1-main.48c7441

7 months ago

0.1.51-main.b442c99

10 months ago

0.3.2-main.4164ba3

7 months ago

0.2.4-main.c33ce2c

7 months ago

0.1.53-main.972e6e3

10 months ago

0.1.53-main.6ef81f0

10 months ago

0.1.53-main.ada9e34

10 months ago

0.2.1-main.4109374

8 months ago

0.1.53-main.b52c368

10 months ago

0.3.2-main.c85979c

7 months ago

0.3.1-main.cf090ba

7 months ago

0.1.52-main.b9b5b8f

10 months ago

0.3.1-main.48d35cc

7 months ago

0.1.53-main.ceb8ff5

10 months ago

0.1.53-main.95559ff

10 months ago

0.1.52-main.787bddf

10 months ago

0.3.3-main.f2ca85a

7 months ago

0.3.2-main.de57e73

7 months ago

0.1.51-main.90930e0

10 months ago

0.3.1-main.320687f

7 months ago

0.1.52-main.34c3c77

10 months ago

0.1.52-main.ceaf79b

10 months ago

0.3.1-main.44a669a

7 months ago

0.2.1-main.9c7e801

7 months ago

0.3.2-main.ec06501

7 months ago

0.3.1-next.2d5b138

7 months ago

0.3.2-main.1fea52c

7 months ago

0.2.2-main.ce5a8a9

7 months ago

0.1.52-main.1744ed2

10 months ago

0.2.4-main.f91937b

7 months ago

0.2.1-main.617b24c

7 months ago

0.1.51-main.21571d3

10 months ago

0.1.51-main.a24503e

10 months ago

0.1.53-main.a0e314e

10 months ago

0.3.1-main.65e00d7

7 months ago

0.2.1-next.60390aa

7 months ago

0.3.1-main.ab5a780

7 months ago

0.1.52

10 months ago

0.1.52-main.9428db3

10 months ago

0.1.53

10 months ago

0.1.54

9 months ago

0.1.52-main.d3eb45f

10 months ago

0.1.55

9 months ago

0.1.56

8 months ago

0.1.57

8 months ago

0.1.51-main.10d68b7

10 months ago

0.1.51

10 months ago

0.2.1-next.f822bf6

7 months ago

0.1.53-main.1377f94

10 months ago

0.3.2-main.0f6af28

7 months ago

0.3.3-main.a79b0bc

7 months ago

0.1.52-main.4bf43ba

10 months ago

0.1.51-main.2bb4663

10 months ago

0.1.52-main.975b35d

10 months ago

0.1.51-main.b7fee56

10 months ago

0.3.0

7 months ago

0.1.53-main.8f662cd

10 months ago

0.3.2

7 months ago

0.3.1

7 months ago

0.2.1-main.0d1583e

7 months ago

0.3.2-main.3e3dd7a

7 months ago

0.3.3-main.85c02fd

7 months ago

0.1.51-next.03aa1a8

10 months ago

0.2.2-main.93531f7

7 months ago

0.1.53-main.823f819

10 months ago

0.2.1-main.dba5399

8 months ago

0.1.53-main.b9267b1

10 months ago

0.2.3-main.2d1ef8a

7 months ago

0.1.51-main.57ad9f3

10 months ago

0.1.51-main.109284c

10 months ago

0.1.52-next.ceaf79b

10 months ago

0.3.2-next.3d933cf

7 months ago

0.3.2-main.45ce889

7 months ago

0.3.2-main.816890d

7 months ago

0.3.2-main.98b13d7

7 months ago

0.1.53-next.db41187

10 months ago

0.2.1-next.b4cb4d5

7 months ago

0.3.2-main.46a9f6a

7 months ago

0.2.1-main.c9d16ae

8 months ago

0.3.2-main.d3a33b8

7 months ago

0.3.1-main.cce3bd1

7 months ago

0.2.1-main.926da04

7 months ago

0.3.1-main.6fd382b

7 months ago

0.2.1-main.315a800

8 months ago

0.1.52-main.18d393e

10 months ago

0.1.53-main.75474bf

10 months ago

0.2.1-main.be48707

8 months ago

0.1.53-main.032dce6

10 months ago

0.2.1-main.c06c65d

8 months ago

0.1.53-main.d095ee3

10 months ago

0.1.53-main.6fd00b0

10 months ago

0.3.3-main.e0ded2e

7 months ago

0.1.53-main.e7b89d1

10 months ago

0.3.2-main.988f99c

7 months ago

0.1.52-main.728c9a2

10 months ago

0.2.1-main.6ad3eea

8 months ago

0.2.1

7 months ago

0.2.0

8 months ago

0.2.2-main.19efe7f

7 months ago

0.2.1-main.1c7a1b5

7 months ago

0.2.3

7 months ago

0.1.51-main.d153dea

10 months ago

0.1.51-main.24977a9

10 months ago

0.1.50

10 months ago

0.1.51-main.b267b99

10 months ago

0.1.50-main.b2c0d7e

10 months ago

0.1.51-main.cb60375

10 months ago

0.1.51-main.e27c9c6

10 months ago

0.1.51-main.c8526c2

10 months ago

0.1.50-main.88a1229

10 months ago

0.1.51-main.23e9d5d

10 months ago

0.1.50-main.c18917d

10 months ago

0.1.50-next.88a1229

10 months ago

0.1.51-main.d71fd8c

10 months ago

0.1.50-main.e80fdfc

10 months ago

0.1.51-main.e7215ae

10 months ago

0.1.51-main.d63f207

10 months ago

0.1.51-main.2c48332

10 months ago

0.1.50-main.3962d45

10 months ago

0.1.51-main.6a6c684

10 months ago

0.1.51-main.b72af36

10 months ago

0.1.51-main.0ebb085

10 months ago

0.1.50-main.29523e1

10 months ago

0.1.51-main.49677b6

10 months ago

0.1.50-main.24fefc9

10 months ago

0.1.50-main.bc31057

10 months ago

0.1.50-main.cab6083

10 months ago

0.1.50-next.3d8b7c4

10 months ago

0.1.50-next.30ca3c7

10 months ago

0.1.50-next.3f38bd5

10 months ago

0.1.50-next.53f1631

10 months ago

0.1.50-next.1bfebf8

10 months ago

0.1.50-next.a27564d

10 months ago

0.1.49

10 months ago

0.1.49-next.7ec9d52

11 months ago

0.1.49-next.c888fc1

11 months ago

0.1.49-next.fdd6c88

11 months ago

0.1.49-next.f1412c7

11 months ago

0.1.49-next.55d8a92

11 months ago

0.1.48

11 months ago

0.1.48-next.806c124

11 months ago

0.1.47

11 months ago

0.1.48-next.366bc83

11 months ago

0.1.48-next.83f55fd

11 months ago

0.1.48-next.4b7ebc3

11 months ago

0.1.46

11 months ago

0.1.46-next.01810f0

11 months ago

0.1.46-next.c3cc04c

11 months ago

0.1.46-next.412561

11 months ago

0.1.45

11 months ago

0.1.45-next.599f154

11 months ago

0.1.45-next.45667d4

11 months ago

0.1.41

1 year ago