Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow granular CSS imports + Fix bundle peer dependencies #195

Merged
merged 25 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
69e04f4
allow granual imports of css files
alexasselin008 Nov 21, 2024
2af8506
update package lock
alexasselin008 Nov 21, 2024
bde7cbd
update article for clarity
alexasselin008 Nov 21, 2024
51276d2
fixed version for peer dependencies
alexasselin008 Nov 21, 2024
3c7a125
Merge all packages under one
alexasselin008 Nov 21, 2024
e218234
update lock file
alexasselin008 Nov 21, 2024
7f7b385
fix peer dep issue
alexasselin008 Nov 21, 2024
00945dc
fix build
alexasselin008 Nov 21, 2024
56b164e
update deps
alexasselin008 Nov 21, 2024
48b908f
test
alexasselin008 Nov 21, 2024
407fe48
remove test runner
alexasselin008 Nov 21, 2024
cd7befa
remove more stuff
alexasselin008 Nov 21, 2024
681551f
remove more stuff
alexasselin008 Nov 21, 2024
e0226f8
Merge branch 'master' into feature/granular_Css
alexasselin008 Nov 21, 2024
e27d26a
add changeset
alexasselin008 Nov 22, 2024
54a637f
Merge branch 'feature/granular_Css' of https://github.com/gsoft-inc/w…
alexasselin008 Nov 22, 2024
abafdd9
add hopper style to storybook
alexasselin008 Nov 22, 2024
c684db4
Merge branch 'master' into feature/granular_Css
alexasselin008 Nov 22, 2024
4c6d039
fix tests
alexasselin008 Nov 22, 2024
54239ea
try to re-run tests for messages
alexasselin008 Nov 22, 2024
afd0ae6
try to rerun all fieldMessage tests
alexasselin008 Nov 22, 2024
4d80bdc
change to force rerun on everything
alexasselin008 Nov 22, 2024
fdf9ce0
Merge branch 'master' into feature/granular_Css
alexasselin008 Nov 22, 2024
c7a6a86
merge conflicts
alexasselin008 Nov 22, 2024
10aa0f1
code review fixes
alexasselin008 Nov 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [["@workleap/orbiter-ui", "@orbit-ui/transition-components"]],
"linked": [],
"access": "public",
"baseBranch": "master",
"updateInternalDependencies": "patch",
Expand Down
5 changes: 5 additions & 0 deletions .changeset/small-students-arrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@workleap/orbiter-ui": patch
---

Hopper UI and react aria components are now properly put as peer dependencies
5 changes: 2 additions & 3 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ let stories: string[] = [];

if (includeDocs) {
stories = [
...stories,
"../docs/**/!(*.stories).mdx",
"../docs/**/*.stories.tsx",
"../packages/**/docs/*.mdx",
Expand All @@ -30,9 +31,7 @@ const storybookConfig: StorybookConfig = {
"@storybook/addon-docs",
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
"@storybook/addon-webpack5-compiler-swc",
"@chromatic-com/storybook"
"@storybook/addon-webpack5-compiler-swc"
],
framework: "@storybook/react-webpack5",
core: {
Expand Down
8 changes: 0 additions & 8 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { viewport } from "./storybook-addon/index.ts";
import { withBackgroundMatchingColorScheme, withCenteredCanvas, ThemedDocsContainer, withThemeProvider } from "./decorators/index.ts";
import { isChromatic } from "./env.ts";
import { Themes } from "./styles/themes.ts";
import { formatCode } from "./components/snippet/index.ts";
import type { Preview } from "@storybook/react";
Expand All @@ -9,13 +8,6 @@ import "./styles/index.ts";
import "@components/index.css";
import "@hopper-ui/tokens/fonts.css";

if (!isChromatic) {
// Custom font makes chromatic inconsistent and cause "false positive". View https://www.chromatic.com/docs/resource-loading#loading-custom-fonts.
import("@css/fonts.css");
} else {
import("./styles/chromatic.css");
}

const preview: Preview = {
parameters: {
backgrounds: {
Expand Down
41 changes: 0 additions & 41 deletions .storybook/stories.css

This file was deleted.

3 changes: 3 additions & 0 deletions .storybook/styles/app.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
@import "@hopper-ui/components/index.css"; /* We use some components in chromatic stories, so we want to make sure the styles are present */


html,
body {
font-family: "Inter", Arial, Helvetica, serif !important;
Expand Down
9 changes: 0 additions & 9 deletions .storybook/styles/chromatic.css

This file was deleted.

75 changes: 75 additions & 0 deletions docs/getting-started/AdvancedCSSImports.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { Meta } from "@storybook/addon-docs";
import { Banner, ExternalLink, Source } from "@stories/components";

<Meta
title="Advanced CSS Imports"
id="AdvancedCSSImports"
/>

# Advanced CSS Imports

<Banner>If you are working with Sharegate, you should use <ExternalLink href="https://orbit.sharegate.design/">Orbit</ExternalLink>.</Banner>

This guide outlines how to customize CSS imports in your project to improve performance and reduce the overall CSS footprint. By replacing the default global import with targeted, granular imports, you can include only the styles you actually need.

## Custom CSS Installation

Instead of importing the entire stylesheet via `@workleap/orbiter-ui/index.css`, selectively include only the required subpackage imports.

Start with the essential imports:

<Source language="css" code={`
/* index.css */

/* @workleap/orbiter-ui/index.css */ /* Skip this import */
@import "@workleap/orbiter-ui/core.css"; /* Base component styles */
`} />

Then, add styles for only the components you use. For example:

<Source language="css" code={`
/* index.css */

@import "@workleap/orbiter-ui/accordion/index.css"; /* For Accordions */
@import "@workleap/orbiter-ui/alert/index.css"; /* For Alerts */
@import "@workleap/orbiter-ui/autocomplete/index.css"; /* For Autocomplete */
@import "@workleap/orbiter-ui/avatar/index.css"; /* For Avatars */
@import "@workleap/orbiter-ui/badge/index.css"; /* For Badges */
@import "@workleap/orbiter-ui/button/index.css"; /* For Buttons */
@import "@workleap/orbiter-ui/card/index.css"; /* For Cards */
@import "@workleap/orbiter-ui/checkbox/index.css"; /* For Checkboxes */
@import "@workleap/orbiter-ui/counter/index.css"; /* For Counters */
@import "@workleap/orbiter-ui/date-input/index.css"; /* For Date Inputs */
@import "@workleap/orbiter-ui/dialog/index.css"; /* For Dialogs */
@import "@workleap/orbiter-ui/disclosure/index.css"; /* For Disclosures */
@import "@workleap/orbiter-ui/divider/index.css"; /* For Dividers */
@import "@workleap/orbiter-ui/dot/index.css"; /* For Dots */
@import "@workleap/orbiter-ui/field/index.css"; /* For Fields */
@import "@workleap/orbiter-ui/form/index.css"; /* For Forms */
@import "@workleap/orbiter-ui/illustrated-message/index.css"; /* For Illustrated Messages */
@import "@workleap/orbiter-ui/illustration/index.css"; /* For Illustrations */
@import "@workleap/orbiter-ui/image/index.css"; /* For Images */
@import "@workleap/orbiter-ui/input-group/index.css"; /* For Input Groups */
@import "@workleap/orbiter-ui/link/index.css"; /* For Links */
@import "@workleap/orbiter-ui/listbox/index.css"; /* For Listboxes */
@import "@workleap/orbiter-ui/loader/index.css"; /* For Loaders */
@import "@workleap/orbiter-ui/lozenge/index.css"; /* For Lozenges */
@import "@workleap/orbiter-ui/menu/index.css"; /* For Menus */
@import "@workleap/orbiter-ui/modal/index.css"; /* For Modals */
@import "@workleap/orbiter-ui/number-input/index.css"; /* For Number Inputs */
@import "@workleap/orbiter-ui/overlay/index.css"; /* For Overlays */
@import "@workleap/orbiter-ui/popover/index.css"; /* For Popovers */
@import "@workleap/orbiter-ui/radio/index.css"; /* For Radios */
@import "@workleap/orbiter-ui/select/index.css"; /* For Selects */
@import "@workleap/orbiter-ui/spinner/index.css"; /* For Spinners */
@import "@workleap/orbiter-ui/switch/index.css"; /* For Switches */
@import "@workleap/orbiter-ui/tabs/index.css"; /* For Tabs */
@import "@workleap/orbiter-ui/tag/index.css"; /* For Tags */
@import "@workleap/orbiter-ui/text-area/index.css"; /* For Text Areas */
@import "@workleap/orbiter-ui/text-input/index.css"; /* For Text Inputs */
@import "@workleap/orbiter-ui/tile/index.css"; /* For Tiles */
@import "@workleap/orbiter-ui/tooltip/index.css"; /* For Tooltips */
`} />

By selectively importing only the CSS you need, you maintain full control over the styles in your project, improving performance and reducing unnecessary CSS.

2 changes: 1 addition & 1 deletion docs/getting-started/Installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pnpm install @workleap/orbiter-ui

## Import styles

Orbiter styles include the ShareGate font, a [CSS bootstrap](https://github.com/gsoft-inc/wl-orbiter/tree/master/packages/css/src) and of course the component's styles.
Orbiter styles include the ShareGate font, a CSS bootstrap and of course the component's styles.

To import Orbiter styles, add the following import declaration to your root stylesheet:

Expand Down
27 changes: 12 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,19 @@
},
"devDependencies": {
"@changesets/cli": "2.27.9",
"@chromatic-com/storybook": "3.2.2",
"@hopper-ui/icons": "2.8.4",
"@hopper-ui/icons": "^2.8.4",
"@hopper-ui/components": "^1.3.33",
"@pmmmwh/react-refresh-webpack-plugin": "0.5.15",
"@storybook/addon-a11y": "8.4.2",
"@storybook/addon-docs": "^8.4.4",
"@storybook/addon-essentials": "8.4.2",
"@storybook/addon-interactions": "8.4.2",
"@storybook/addon-links": "8.4.2",
"@storybook/addon-mdx-gfm": "8.4.2",
"@storybook/addon-a11y": "8.4.5",
"@storybook/addon-docs": "8.4.5",
"@storybook/addon-essentials": "8.4.5",
"@storybook/addon-links": "8.4.5",
"@storybook/addon-mdx-gfm": "8.4.5",
"@storybook/addon-webpack5-compiler-swc": "1.0.5",
"@storybook/blocks": "8.4.2",
"@storybook/react": "8.4.2",
"@storybook/react-webpack5": "8.4.2",
"@storybook/test": "8.4.2",
"@storybook/test-runner": "0.19.1",
"@storybook/types": "8.4.2",
"@storybook/blocks": "8.4.5",
"@storybook/react": "8.4.5",
"@storybook/react-webpack5": "8.4.5",
"@storybook/types": "8.4.5",
"@svgr/core": "6.5.1",
"@swc/core": "1.7.36",
"@swc/helpers": "0.5.13",
Expand Down Expand Up @@ -107,7 +104,7 @@
"resize-observer-polyfill": "1.5.1",
"serve": "14.2.4",
"shelljs": "0.8.5",
"storybook": "8.4.2",
"storybook": "8.4.5",
"stylelint": "^16.10.0",
"svgo": "3.3.2",
"ts-jest": "29.2.5",
Expand Down
Loading