Skip to content

Commit

Permalink
Adopt global-css in Squared and Squareone
Browse files Browse the repository at this point in the history
This drops the initiative to build a GlobalStyles component in squared
and instead switches us back to using a CSS import for the global style.

The main benefit of this final arrangement is that now we can but all
the business of integrating Rubin Style Dictionary components into the
global CSS into a dedicated CSS module, global-css, rather than needing
to do it in every application.

A limitation of this approach is that we're still not centralizing the
font import; but I'm not sure there's a good way to do that. We'll just
have to document how we load fonts. And with variable fonts this might
become easier too.
  • Loading branch information
jonathansick committed Aug 11, 2023
1 parent 826c9b6 commit 3561d09
Show file tree
Hide file tree
Showing 14 changed files with 13 additions and 185 deletions.
5 changes: 5 additions & 0 deletions .changeset/afraid-spoons-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'squareone': minor
---

Squareone uses a base stylesheet from the @lsst-sqre/global-css package. This reduces the amount of global CSS managed in Squareone itself, and offloads configuring the Rubin Style Dictionary tokens into base CSS elements.
7 changes: 1 addition & 6 deletions apps/squareone/.storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ import '@fontsource/source-sans-pro/700.css';
// Global CSS
import 'normalize.css';
import '@fortawesome/fontawesome-svg-core/styles.css';
// import '@lsst-sqre/rubin-style-dictionary/dist/tokens.css';
// import '@lsst-sqre/rubin-style-dictionary/dist/tokens.dark.css';
import '@lsst-sqre/global-css/dist/next.css';
import '../src/styles/globals.css';
import '../src/styles/icons';

import { withGlobalStyles } from './decorators';

export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
Expand All @@ -26,5 +23,3 @@ export const parameters = {
},
},
};

export const decorators = [withGlobalStyles];
1 change: 1 addition & 0 deletions apps/squareone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@fortawesome/fontawesome-svg-core": "^6.3.0",
"@fortawesome/free-solid-svg-icons": "^6.3.0",
"@fortawesome/react-fontawesome": "^0.2.0",
"@lsst-sqre/global-css": "workspace:*",
"@lsst-sqre/rubin-style-dictionary": "workspace:*",
"@lsst-sqre/squared": "workspace:*",
"@reach/alert": "^0.17.0",
Expand Down
5 changes: 1 addition & 4 deletions apps/squareone/src/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ import '@fontsource/source-sans-pro/400-italic.css';
import '@fontsource/source-sans-pro/700.css';
import 'normalize.css';
import '@fortawesome/fontawesome-svg-core/styles.css';
// import '@lsst-sqre/rubin-style-dictionary/dist/tokens.css';
// import '@lsst-sqre/rubin-style-dictionary/dist/tokens.dark.css';
import '@lsst-sqre/global-css/dist/next.css';
import '../styles/globals.css';
import '../styles/icons';

import Page from '../components/Page';
import { GlobalStyles } from '@lsst-sqre/squared';

function MyApp({ Component, pageProps, baseUrl, semaphoreUrl }) {
// Use the content layout defined by the page component, if avaialble.
Expand All @@ -26,7 +24,6 @@ function MyApp({ Component, pageProps, baseUrl, semaphoreUrl }) {
/* eslint-disable react/jsx-props-no-spreading */
return (
<ThemeProvider defaultTheme="system">
<GlobalStyles />
<Page baseUrl={baseUrl} semaphoreUrl={semaphoreUrl}>
{getLayout(<Component {...pageProps} />)}
</Page>
Expand Down
1 change: 0 additions & 1 deletion apps/squareone/src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
--sqo-transition-basic: 0.3s ease all;
}


/*
* Design token overrides for dark theme.
*/
Expand Down
13 changes: 0 additions & 13 deletions packages/squared/.storybook/decorators.tsx

This file was deleted.

3 changes: 1 addition & 2 deletions packages/squared/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { Preview } from '@storybook/react';
import { withThemeByDataAttribute } from '@storybook/addon-styling';
import { withGlobalStyles } from './decorators';

// Import font assets and stylesheets with @font-face declarations
import '@fontsource/source-sans-pro/400.css';
import '@fontsource/source-sans-pro/400-italic.css';
import '@fontsource/source-sans-pro/700.css';
import '@lsst-sqre/global-css/dist/next.css';

const preview: Preview = {
parameters: {
Expand All @@ -26,7 +26,6 @@ export default preview;
// ThemeProvider directly; see
// https://github.com/storybookjs/addon-styling/blob/next/docs/api.md#withthemefromjsxprovider
export const decorators = [
withGlobalStyles,
withThemeByDataAttribute({
themes: {
light: 'light',
Expand Down
1 change: 1 addition & 0 deletions packages/squared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"dependencies": {
"@fontsource/source-sans-pro": "^4.5.11",
"@lsst-sqre/rubin-style-dictionary": "workspace:*",
"@lsst-sqre/global-css": "workspace:*",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"styled-components": "^5.3.6"
Expand Down
1 change: 0 additions & 1 deletion packages/squared/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';

export { Button, type ButtonProps } from './Button';
export { GlobalStyles } from './styles';
73 changes: 0 additions & 73 deletions packages/squared/src/styles/base.css

This file was deleted.

Empty file.
84 changes: 0 additions & 84 deletions packages/squared/src/styles/globalStyles.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/squared/src/styles/index.ts

This file was deleted.

3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3561d09

Please sign in to comment.