Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@amboss/design-system
Advanced tools
Development
npm install
npm run start
Building package
npm run build
Building storybook
npm run build-storybook
Code: typescript + scss Framework: react Bundler: webpack Environment: storybook Tokens: style-dictionary Testing: jest + react testing library
|-- .storybook |-- components |-- ColorGrid.tsx |-- SizeGrid.tsx |-- main.js |-- preview.js |-- assets |-- fonts |-- Lato.woff |-- build (autogenerated) |-- build-tokens (autogenerated) |-- _assets_fonts.scss |-- _variables.scss |-- _theme.scss |-- _colors.json |-- _theme.json |-- docs |-- Design-principles.mdx |-- tokens |-- themes |-- dark.json |-- light.json |-- assets.json |-- colors.json |-- src |-- components |-- Button |-- Button.tsx |-- Button.scss |-- Button.scss.d.ts (autogenerated) |-- Button.stories.tsx |-- Button.test.tsx |-- shared-styles |-- _fonts.scss |-- types |-- index.ts |-- index.ts
There are 3 stages of a build.
Files like Button.scss.d.ts
are autogenerated, and they are added to .gitignore.
Type definitions are generating automatically:
npm run start
is runningYou can generate *d.ts manually using npm run type-styles
and npm run type-styles:watch
Why we need *.d.ts for styles?
In order to structure our tokens we use style-dictionary.
This tool is used for creation a content of ./build-tokens
folder where we keep all the scss variables and mixins.
New variables and mixins gets generated automaticaly:
npm run start
is runningYou can generate tokens manually using npm run tokens
and npm run tokens:watch
We use tokens to control the most atomic values in styles and themes.
How does it work?
We have a set of .json files that are located in ./tokens
folder, and we have a style-dictionary
as a tool for converting .json in to various formats.
For example:
We have a file - ./tokens/colors.json
that gets converted into ./build-tokens/_variables.scss
and ./build-tokens/_colors.json
.
_variables.scss
is directly imported in other .scss
files.
_colors.json
is imported inside ./.storybook/components/ColorGrid.tsx
in order to present in storybook all the colors we currently have.
The configuration for style-dictionary
is inside ./style-dictionary.config.json
. In this config we use 2 custom formatters and 1 custom filter, all of them defined in ./style-dictionary.build.js
.
custom/format/scss - a formatter that is used for generation a .json files for tokens like colors, size, weight and so on. These .json files are imported in storybook for presentation.
custom/format/theme-scss - a formatter that is used for generation a _theme.scss
that contains a @theme
mixin.
custom/filter/only-vars - a filter for excluding theme and assets from processing them as variables.
More about tokens, themes and styles.
Before publish the design system for npm we run npm run build
that bundles everything that is exported from ./src/index.ts
.
We use webpack + typescript for bundling. For all /\.ts(x?)$/
files webpack uses a ts-loader as a rule which is implicitly using tsconfig.json
.
For styles we use sass-loader + css-loader with enabled modules for namespacing all css selectors.
What in the bundle?
We use type definitions for style in order to improve quality of a product overall. One example:
import styles from './button.scss';
type ButtonProps = {
size: 's' | 'm' | 'l'
}
export const Button = ({size}: ButtonProps) => (
<button className={styles[size]} />
)
Here with type definitions we are sure that button.scss
contain all 3 classes (.s, .m, and .l). Otherwise, it won't compile.
Currently, we have 3 types of tokens:
Atomic values and font assets are straight forward and simply converted to scss variables.
After build all atomic values can't be imported as @import "build-tokens/variables";
Fonts are imported inside ./src/shared-styles/_fonts
and never used directly (it doesn't make sense).
In the application simply @import "src/shared-styles/fonts";
.
Theme values are little more complex. When theme token is precessed we generate several entities. All of them are located in ./build-tokens/_theme.scss
@theme
mixin, that include all themes.As the result developers are free to use a @theme
mixin for particular css properties with no worries about active theme and amount of themes.
Example:
@import "build-tokens/theme";
@import "build-tokens/variables";
@import "src/shared-styles/fonts";
.primary {
@include theme('color', $theme-color-text-primary);
font-family: $Lato;
margin: 0;
}
.secondary {
@include theme('color', $theme-color-text-secondary);
}
.s {
font-size: $size-font-text-s;
line-height: $size-font-text-line-height-s;
}
.m {
font-size: $size-font-text-m;
line-height: $size-font-text-line-height-m;
}
.normal {
font-weight: $weight-normal;
}
.bold {
font-weight: $weight-bold;
}
FAQs
the design system for AMBOSS products
The npm package @amboss/design-system receives a total of 2,459 weekly downloads. As such, @amboss/design-system popularity was classified as popular.
We found that @amboss/design-system demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.