@chotot/clad-ui 3.0.0-next.1 → 3.0.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -1
- package/ai/clad-ui-helper.js +267 -0
- package/ai/knowledge-base/README.md +154 -0
- package/ai/knowledge-base/clad-ui-database.json +9378 -0
- package/ai/knowledge-base/component-categories.json +616 -0
- package/ai/knowledge-base/components/metadata/charts-axis.json +31 -0
- package/ai/knowledge-base/components/metadata/charts-barchart.json +57 -0
- package/ai/knowledge-base/components/metadata/charts-basechart.tsx.json +31 -0
- package/ai/knowledge-base/components/metadata/charts-chartshared.json +31 -0
- package/ai/knowledge-base/components/metadata/charts-linechart.json +189 -0
- package/ai/knowledge-base/components/metadata/charts-piechart.json +57 -0
- package/ai/knowledge-base/components/metadata/components-announcer.json +215 -0
- package/ai/knowledge-base/components/metadata/components-badge.json +168 -0
- package/ai/knowledge-base/components/metadata/components-box.json +348 -0
- package/ai/knowledge-base/components/metadata/components-breadcrumbs.json +75 -0
- package/ai/knowledge-base/components/metadata/components-button.json +187 -0
- package/ai/knowledge-base/components/metadata/components-checkbox.json +161 -0
- package/ai/knowledge-base/components/metadata/components-chip.json +266 -0
- package/ai/knowledge-base/components/metadata/components-currencyinput.json +136 -0
- package/ai/knowledge-base/components/metadata/components-datepicker.json +87 -0
- package/ai/knowledge-base/components/metadata/components-dropdown.json +282 -0
- package/ai/knowledge-base/components/metadata/components-grid.json +92 -0
- package/ai/knowledge-base/components/metadata/components-input.json +432 -0
- package/ai/knowledge-base/components/metadata/components-pagination.json +111 -0
- package/ai/knowledge-base/components/metadata/components-popover.json +63 -0
- package/ai/knowledge-base/components/metadata/components-radiobutton.json +170 -0
- package/ai/knowledge-base/components/metadata/components-rowitem.json +281 -0
- package/ai/knowledge-base/components/metadata/components-shapeicon.json +139 -0
- package/ai/knowledge-base/components/metadata/components-slider.json +177 -0
- package/ai/knowledge-base/components/metadata/components-snack.json +181 -0
- package/ai/knowledge-base/components/metadata/components-tabs.json +169 -0
- package/ai/knowledge-base/components/metadata/components-textarea.json +285 -0
- package/ai/knowledge-base/components/metadata/components-textlabel.json +129 -0
- package/ai/knowledge-base/components/metadata/components-toggleswitch.json +134 -0
- package/ai/knowledge-base/components/metadata/components-tooltip.json +291 -0
- package/ai/knowledge-base/components/metadata/patterns-drawer.json +310 -0
- package/ai/knowledge-base/components/metadata/patterns-emptystate.json +106 -0
- package/ai/knowledge-base/components/metadata/patterns-inputgroup.json +105 -0
- package/ai/knowledge-base/components/metadata/patterns-legacydialog.json +177 -0
- package/ai/knowledge-base/components/metadata/patterns-legacypopup.json +236 -0
- package/ai/knowledge-base/components/metadata/patterns-multisearchdropdown.json +249 -0
- package/ai/knowledge-base/components/metadata/patterns-popup.json +268 -0
- package/ai/knowledge-base/components/metadata/patterns-rangeinput.json +105 -0
- package/ai/knowledge-base/components/metadata/patterns-searchbar.json +150 -0
- package/ai/knowledge-base/components/metadata/patterns-searchinput.json +312 -0
- package/ai/knowledge-base/components/metadata/patterns-tagcloud.json +244 -0
- package/ai/knowledge-base/components/metadata/summaries.json +610 -0
- package/ai/knowledge-base/design-tokens/tokens.json +483 -0
- package/ai/knowledge-base/patterns/documentation.json +131 -0
- package/ai/knowledge-base/prompts/common-system-prompt.md +592 -0
- package/ai/knowledge-base/prompts/figma-system-prompt.md +396 -0
- package/ai/knowledge-base/search-index/icons/asset-icons.json +1 -0
- package/ai/knowledge-base/search-index/icons/collection.json +5 -0
- package/ai/knowledge-base/search-index/icons/system-icons.json +1 -0
- package/ai/knowledge-base/search-index/search-index.json +899 -0
- package/ai/knowledge-base/validation-rules/component-rules.json +658 -0
- package/ai/skill/SKILL.md +103 -0
- package/dist/clad-ui.es.js +1110 -1098
- package/dist/components/Chip/Chip.d.ts +1 -1
- package/dist/components/Chip/Chip.d.ts.map +1 -1
- package/dist/components/Chip/Chip.styles.d.ts.map +1 -1
- package/dist/components/Input/Input.styles.d.ts.map +1 -1
- package/dist/components/RowItem/RowItem.styles.d.ts.map +1 -1
- package/dist/components/Snack/Snack.d.ts +9 -0
- package/dist/components/Snack/Snack.d.ts.map +1 -1
- package/dist/components/Snack/Snack.styles.d.ts +7 -1
- package/dist/components/Snack/Snack.styles.d.ts.map +1 -1
- package/dist/components/TextArea/TextArea.styles.d.ts.map +1 -1
- package/dist/patterns/Drawer/Drawer.d.ts +19 -10
- package/dist/patterns/Drawer/Drawer.d.ts.map +1 -1
- package/dist/patterns/Drawer/Drawer.styles.d.ts +1 -1
- package/dist/patterns/Drawer/Drawer.styles.d.ts.map +1 -1
- package/dist/patterns/MultiSearchDropdown/MultiSearchDropdown.d.ts.map +1 -1
- package/dist/patterns/MultiSearchDropdown/MultiSearchDropdown.styles.d.ts.map +1 -1
- package/dist/theme-chotot.css +1 -1
- package/dist/theme-job.css +1 -1
- package/dist/theme-pty.css +1 -1
- package/dist/theme-veh.css +1 -1
- package/package.json +8 -2
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
{
|
|
2
|
+
"styleGuide": [
|
|
3
|
+
{
|
|
4
|
+
"frontmatter": {},
|
|
5
|
+
"content": "import { Meta } from '@storybook/addon-docs/blocks';\n\n<Meta\n title=\"Style Guide/Layout/Breakpoints\"\n parameters={{ previewTabs: { canvas: { hidden: true } } }}\n/>\n\n# Breakpoints\n\nBreakpoints are predefined widths in theme object that determine how responsive layout behaves across device or viewport sizes in Clad UI.\n\n## Core concepts\n\n- **Breakpoints are part of the design tokens** defined in theme specification. They can be overriden or customized in custom theme object.\n- **Mobile first, responsive design is the goal**. Media queries must use `min-width` to apply the bare minimum of styles to make a layout work at the smallest breakpoint, and then layers on styles to adjust that design for larger devices.\n- **Breakpoints-aware components uses [array props](https://styled-system.com/guides/array-props/)** as universal API for responsive design.\n\n## Available Breakpoints\n\nWe use the same scale name with [Bootstrap breakpoints class infix](https://getbootstrap.com/docs/5.0/layout/breakpoints/) and dimensions for easy reference and association.\n\n| Breakpoint | Array Prop Index | Scale Name | Dimensions |\n| ----------------- | ---------------- | ---------- | ---------- |\n| Extra Small | [0] | None | <576px |\n| Small | [1] | **sm** | ≥576px |\n| Medium | [2] | **md** | ≥768px |\n| Large | [3] | **lg** | ≥992px |\n| Extra large | [4] | **xl** | ≥1280px |\n| Extra extra large | [5] | **xxl** | ≥1440px |\n\n## Design Tokens\n\nThese breakpoints can be referred from design tokens (theme objects) using both Array index and Clad UI scale naming:\n\n```\ntheme.breakpoints.[ 0 | 1 | 2 | 3 | 4 ]\n\ntheme.breakpoints.[ sm | md | lg | xl | xxl ]\n```\n\n**Note:** Indexed breakpoints starts from the first media query (`theme.breakpoints[0] = '576px'` ) and it is **not consistent** with array prop indices. Therefore, avoid using theme breakpoints indices, and use scale names (`sm`, `md`, `lg`...) instead. Besides current breakpoints step by name is identical with Bootstrap's counter parts.\n\n## Media Queries\n\nWrite explicit media queries with theme's breakpoints:\n\n```js\nimport theme from '@chotot/clad-ui/theme';\n\nconst { breakpoints } = theme;\n\nconst StyledCol = styled.div`\n font-size: ${theme.fontSizes.sm};\n padding: ${theme.space.md};\n\n @media (min-width: ${breakpoints.sm}) {\n font-size: ${theme.fontSizes.md};\n padding: ${theme.space.lg};\n }\n\n @media (min-width: ${breakpoints.md}) {\n padding: ${theme.space.xl};\n }\n`\n```\n\n### Chotot Media Query Aliases\n\nTheme object `mediaQueries` key add some shortcuts to the full media query line and is specific to different systems. Currently, Chotot web design system only concern 2 major breakpoints: msite (phone, no-prefix) and \"desktop\" (actually tablet and up, `md`). So we added following media query shortcuts to the `mediaQueries` theme key:\n\n```js\nimport theme from '@chotot/clad-ui/theme';\n\nconst { mediaQueries } = theme;\n\nconst StyledCol = styled.div`\n /* direct rules are for msite */\n font-size: ${theme.fontSizes.sm};\n padding: ${theme.space.md};\n\n /* for so-called \"desktop\" */\n @media ${mediaQueries.tablet} {\n font-size: ${theme.fontSizes.md};\n padding: ${theme.space.lg};\n }\n\n /* for actual desktop */\n @media ${mediaQueries.desktop} {\n font-size: ${theme.fontSizes.md};\n padding: ${theme.space.lg};\n }\n`\n```\n\n> Note: since `mediaQueries` is derived (but immutable) from `breakpoints`, we avoid using `mediaQueries` within Clad UI components since developers might customize `breakpoints` and forget to sync `mediaQueries`.\n\n## Responsive Props\n\nClad UI components uses [array props](https://styled-system.com/guides/array-props/) API for responsive configuration.\n\n```jsx\n// Set the value for each breakpoints in the array prop\n<Grid rowCols=[\n 1, // 1 column below the smallest breakpoint (default)\n 2, // 2 columns from the small breakpoint and up\n null, // skipped, so reuse 2 columns for the medium breakpoint\n 3, // 3 columns from the large breakpoint and up\n]\n/>\n// NOTE: to skip a breakpoint, use `null` or repeated value\n\n// Responsive padding from default, small and medium breakpoints\n<Box padding=[\"sm\", \"md\", \"lg\"] />\n\n// Use same padding for all breakpoints\n<Box padding=\"md\" />\n\n```\n\n\n## The case of iPhone 5 (≤320px).\n\nThere are some rare cases in which we found a layout / visual bug with small phone screen size (most commonly, it is iPhone 5 and below). Since these cases are not common, we'll add some custom classes and styles (with `max-width` media query) to fix them instead of adding a responsive breakpoint step globally.\n\n```js\nimport theme from '@chotot/clad-ui/theme';\n\nconst { mediaQueries } = theme;\n\nconst MyComponent = styled.div`\n /* style for common phone and up (>320px) */\n font-size: ${theme.fontSizes.sm};\n\n /* for iPhone 5 and below */\n @media (max-width: 320px) {\n font-size: ${theme.fontSizes.xs};\n }\n\n /* OR use Chotot theme mediaQueries alias */\n @media ${mediaQueries.ip5} {\n font-size: ${theme.fontSizes.xs};\n }\n`\n```\n\n## Customize Breakpoints\n\nIn case you want to customize the breakpoints, make sure you define values for both array index and properties of the `breakpoints` key:\n\n```js\n// in the project local theme's alias (usually src/theme/index.js)\nimport theme from '@chotot/clad-ui/theme/chotot';\n\n// for example: tweaking the small and medium breakpoints\nconst breakpoints = ['320px', '576px', '992px', '1280px', '1440px'];\n\n// define the named breakpoints based on the array\n[breakpoints.sm, breakpoints.md, breakpoints.lg, breakpoints.xl, breakpoints.xxl] = breakpoints;\n\nconst appTheme = {\n ...theme,\n breakpoints,\n mediaQueries: {\n // redefine mediaQueries if necessary\n }\n}\n\nexport default appTheme;\n```\n\n## The getBreakpointsValues helper\n\nTo generate the values for each breakpoints in styled-system conveniently, Clad-UI provides `getBreakpointsValues` helper function that generates **an array with 5 elements** from a number or another array with less than 5 elements.\n\n```js\nimport { getBreakpointsValues } from '@chotot/clad-ui/utils';\n\ngetBreakpointsValues(4, 'initial'); // [4, 4, 4, 4, 4]\ngetBreakpointsValues([2, null, 4], 'initial'); // [2, 2, 4, 4, 4]\ngetBreakpointsValues([], 'initial'); // ['initial', 'initial', 'initial', 'initial', 'initial']\n```\n\n## Other media query helpers\n\nBootstrap 5 has more media query helpers such as `media-breakpoint-down` (desktop-first), `media-breakpoint-only`, and `media-breakpoint-between`. However, **we don't support these helpers for now** and discourage writing plain media queries trying those approaches as they are against mobile-first principles (unless there are circumstances using them will help with CSS parsing performance).\n",
|
|
6
|
+
"title": "Style Guide/Layout/Breakpoints",
|
|
7
|
+
"description": "Breakpoints are predefined widths in theme object that determine how responsive layout behaves across device or viewport sizes in Clad UI.",
|
|
8
|
+
"filePath": "website/style-guide/3.7-layout-breakpoints.stories.mdx"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"frontmatter": {},
|
|
12
|
+
"content": "import { Meta } from '@storybook/addon-docs/blocks';\n\n<Meta title=\"Style Guide/Baseline CSS\" parameters={{ previewTabs: { canvas: { hidden: true } } }} />\n\n# Baseline CSS\n\n## Usage\n\nBaseline CSS uses Linaria's unscoped global styles so we can import it as side effect:\n\n```js\n// in the entry component (app.js, _app.js...)\nimport '@chotot/clad-ui/css/baseline';\n```\n\n> **Note:** baseline CSS module may be treeshaked from bundle because of its side effect nature. We have marked side effect modules in @chotot/clad-ui's `package.json` and it should fix this issue with Webpack 4+. If you have this issue with other bundler, import the module as if it is pure dependent module like so:\n> ```js\n> import baselineCSS from '@chotot/clad-ui/css/baseline';\n> console.log(baselineCSS); // make bundler's parser see it being used to be included in bundle.\n> ```\n\n\n## Approach\n\nClad UI Baseline CSS is based on [Bootstrap's Reboot](https://getbootstrap.com/docs/5.0/content/reboot/), providing many HTML elements with somewhat opinionated styles using only **element selectors**. This serves as both cross-browser CSS normalization and decent default styles for HTML documents that match Clad UI design system.\n\nHere are our guidelines and reasons for choosing what to override in Clad UI Baseline CSS:\n\n- Update some browser default values to use `rem`s instead of `em`s for scalable component spacing.\n- Avoid `margin-top`. Vertical margins can collapse, yielding unexpected results. More importantly though, a single direction of `margin` is a simpler mental model.\n- For easier scaling across device sizes, block elements should use `rem`s for `margin`s.\n- Keep declarations of `font`-related properties to a minimum, using `inherit` whenever possible.\n\n## Page defaults\n\nThe `<html>` and `<body>` elements are updated to provide better page-wide defaults. More specifically:\n\n- The `box-sizing` is globally set on every element—including `*::before` and `*::after`, to `border-box`. This ensures that the declared width of element is never exceeded due to padding or border.\n- No base `font-size` is declared on the `<html>`, but `16px` is assumed (the browser default). `font-size: ${theme.fontSizes.body}` is applied on the `<body>` for easy responsive type-scaling via media queries while respecting user preferences and ensuring a more accessible approach. This browser default can be overridden by modifying the `fontSizes.body` theme key.\n- The `<body>` also sets a global `font-family`, `font-weight`, `line-height`, and `color`. This is inherited later by some form elements to prevent font inconsistencies.\n\n## Font stack\n\nClad UI Baseline CSS utilizes a \"native font stack\" or \"system font stack\" for optimum text rendering and somewhat consistent on every device and OS.\n\n```css\nbody {\n font-family:\n Helvetica, /* macOS & iOS */\n Arial, /* Windows */\n Roboto, /* Android */\n sans-serif; /* Sans serif fallback & Linux */\n}\n```\n\nThis `font-family` is applied to the `<body>` and automatically inherited globally throughout Baseline CSS. To switch the global `font-family`, update `theme.fonts.body` in theme object overrides.\n\n## Headings and paragraphs\n\nAll heading elements—e.g., `<h1>`—and `<p>` are reset to have their `margin-top` removed. Headings and paragraphs have `margin-bottom` added with theme's `space` tokens for easy spacing.\n\n<table class=\"table\">\n <thead>\n <tr>\n <th>Heading</th>\n <th>Example</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>\n <h1></h1>\n </td>\n <td><h1>h1. Baseline heading</h1></td>\n </tr>\n <tr>\n <td>\n <h2></h2>\n </td>\n <td><h2>h2. Baseline heading</h2></td>\n </tr>\n <tr>\n <td>\n <h3></h3>\n </td>\n <td><h3>h3. Baseline heading</h3></td>\n </tr>\n <tr>\n <td>\n <h4></h4>\n </td>\n <td><h4>h4. Baseline heading</h4></td>\n </tr>\n <tr>\n <td>\n <h5></h5>\n </td>\n <td><h5>h5. Baseline heading</h5></td>\n </tr>\n <tr>\n <td>\n <h6></h6>\n </td>\n <td><h6>h6. Baseline heading</h6></td>\n </tr>\n </tbody>\n</table>\n\n## Lists\n\nAll lists—`<ul>`, `<ol>`, and `<dl>`—have their `margin-top` removed and a `margin-bottom: 1rem`. Nested lists have no `margin-bottom`. We've also reset the `padding-left` on `<ul>` and `<ol>` elements.\n\n<div class=\"baseline-example\">\n <ul>\n <li>All lists have their top margin removed</li>\n <li>And their bottom margin normalized</li>\n <ul>\n <li>Nested lists have no bottom margin</li>\n <li>This way they have a more even appearance</li>\n <li>Particularly when followed by more list items</li>\n </ul>\n <li>The left padding has also been reset</li>\n </ul>\n\n <ol>\n <li>Here's an ordered list</li>\n <li>With a few list items</li>\n <li>It has the same overall look</li>\n <li>As the previous unordered list</li>\n </ol>\n</div>\n\nFor simpler styling, clear hierarchy, and better spacing, description lists have updated `margin`s. `<dd>`s reset `margin-left` to `0` and add `margin-bottom: .5rem`. `<dt>`s are **bolded**.\n\n<div class=\"baseline-example\">\n <dl>\n <dt>Description lists</dt>\n <dd>A description list is perfect for defining terms.</dd>\n <dt>Term</dt>\n <dd>Definition for the term.</dd>\n <dd>A second definition for the same term.</dd>\n <dt>Another term</dt>\n <dd>Definition for this other term.</dd>\n </dl>\n</div>\n\n## Inline code\n\nWrap inline snippets of code with `<code>`. Be sure to escape HTML angle brackets.\n\n<div class=\"baseline-example\">\n For example, <code><section></code> should be wrapped as inline.\n</div>\n\n```html\n For example, <code><section></code> should be wrapped as inline.\n```\n\n## Code blocks\n\nUse `<pre>`s for multiple lines of code. Once again, be sure to escape any angle brackets in the code for proper rendering. The `<pre>` element is reset to remove its `margin-top` and use `rem` units for its `margin-bottom`.\n\n\n<div class=\"baseline-example\">\n <pre><code>\n <p>Sample text here...</p><br/>\n <p>And another line of sample text here...</p>\n </code></pre>\n</div>\n\n```html\n<pre><code>\n <p>Sample text here...</p>\n <p>And another line of sample text here...</p>\n</code></pre>\n```\n\n## User input\n\nUse the `<kbd>` to indicate input that is typically entered via keyboard.\n\n<div class=\"baseline-example\">\nTo switch directories, type <kbd>cd</kbd> followed by the name of the directory.<br/>\nTo edit settings, press <kbd><kbd>ctrl</kbd> + <kbd>,</kbd></kbd>\n</div>\n\n```html\nTo switch directories, type <kbd>cd</kbd> followed by the name of the directory.<br/>\nTo edit settings, press <kbd><kbd>ctrl</kbd> + <kbd>,</kbd></kbd>\n```\n\n## Sample output\n\nFor indicating sample output from a program use the `<samp>` tag.\n\n<div class=\"baseline-example\">\n<samp>This text is meant to be treated as sample output from a computer program.</samp>\n</div>\n\n```html\n<samp>This text is meant to be treated as sample output from a computer program.</samp>\n```\n\n## Tables\n\nTables are slightly adjusted to style `<caption>`s, collapse borders, and ensure consistent `text-align` throughout.\n\n<div class=\"baseline-example\">\n <table>\n <caption>\n This is an example table, and this is its caption to describe the contents.\n </caption>\n <thead>\n <tr>\n <th>Table heading</th>\n <th>Table heading</th>\n <th>Table heading</th>\n <th>Table heading</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>Table cell</td>\n <td>Table cell</td>\n <td>Table cell</td>\n <td>Table cell</td>\n </tr>\n <tr>\n <td>Table cell</td>\n <td>Table cell</td>\n <td>Table cell</td>\n <td>Table cell</td>\n </tr>\n <tr>\n <td>Table cell</td>\n <td>Table cell</td>\n <td>Table cell</td>\n <td>Table cell</td>\n </tr>\n </tbody>\n </table>\n</div>\n\n## Forms\n\nVarious form elements have been rebooted for simpler base styles. Here are some of the most notable changes:\n\n- `<fieldset>`s have no borders, padding, or margin so they can be easily used as wrappers for individual inputs or groups of inputs.\n- `<legend>`s, like fieldsets, have also been restyled to be displayed as a heading of sorts.\n- `<label>`s are set to `display: inline-block` to allow `margin` to be applied.\n- `<input>`s, `<select>`s, `<textarea>`s, and `<button>`s are mostly addressed by Normalize, but Reboot removes their `margin` and sets `line-height: inherit`, too.\n- `<textarea>`s are modified to only be resizable vertically as horizontal resizing often \"breaks\" page layout.\n- `<button>`s and `<input>` button elements have `cursor: pointer` when `:not(:disabled)`.\n\nThese changes, and more, are demonstrated below.\n\n<form class=\"baseline-example\">\n <fieldset>\n <legend>Example legend</legend>\n <p>\n <label for=\"input\">Example input</label> \n <input type=\"text\" id=\"input\" placeholder=\"Example input\"/>\n </p>\n <p>\n <label for=\"email\">Example email</label> \n <input type=\"email\" id=\"email\" placeholder=\"test@example.com\"/>\n </p>\n <p>\n <label for=\"tel\">Example telephone</label> \n <input type=\"tel\" id=\"tel\"/>\n </p>\n <p>\n <label for=\"url\">Example url</label> \n <input type=\"url\" id=\"url\"/>\n </p>\n <p>\n <label for=\"number\">Example number</label> \n <input type=\"number\" id=\"number\"/>\n </p>\n <p>\n <label for=\"search\">Example search</label> \n <input type=\"search\" id=\"search\"/>\n </p>\n <p>\n <label for=\"range\">Example range</label> \n <input type=\"range\" id=\"range\" min=\"0\" max=\"10\"/>\n </p>\n <p>\n <label for=\"file\">Example file input</label> \n <input type=\"file\" id=\"file\"/>\n </p>\n <p>\n <label for=\"select\">Example select</label> \n <select id=\"select\">\n <option value=\"\">Choose...</option>\n <optgroup label=\"Option group 1\">\n <option value=\"\">Option 1</option>\n <option value=\"\">Option 2</option>\n <option value=\"\">Option 3</option>\n </optgroup>\n <optgroup label=\"Option group 2\">\n <option value=\"\">Option 4</option>\n <option value=\"\">Option 5</option>\n <option value=\"\">Option 6</option>\n </optgroup>\n </select>\n </p>\n <p>\n <label>\n <input type=\"checkbox\" value=\"\" /> \n Check this checkbox\n </label>\n </p>\n <p>\n <label>\n <input type=\"radio\" name=\"optionsRadios\" id=\"optionsRadios1\" value=\"option1\" checked /> \n Option one is this and that\n </label>\n <label>\n <input type=\"radio\" name=\"optionsRadios\" id=\"optionsRadios2\" value=\"option2\" /> \n Option two is something else that's also super long to demonstrate the wrapping of these fancy form controls.\n </label>\n <label>\n <input type=\"radio\" name=\"optionsRadios\" id=\"optionsRadios3\" value=\"option3\" disabled /> \n Option three is disabled\n </label>\n </p>\n <p>\n <label for=\"textarea\">Example textarea</label> \n <textarea id=\"textarea\" rows=\"3\"></textarea>\n </p>\n <p>\n <label for=\"date\">Example date</label> \n <input type=\"date\" id=\"date\" />\n </p>\n <p>\n <label for=\"time\">Example time</label> \n <input type=\"time\" id=\"time\" />\n </p>\n <p>\n <label for=\"password\">Example password</label> \n <input type=\"password\" id=\"password\" />\n </p>\n <p>\n <label for=\"datetime-local\">Example datetime-local</label> \n <input type=\"datetime-local\" id=\"datetime-local\" />\n </p>\n <p>\n <label for=\"week\">Example week</label> \n <input type=\"week\" id=\"week\" />\n </p>\n <p>\n <label for=\"month\">Example month</label> \n <input type=\"month\" id=\"month\" />\n </p>\n <p>\n <label for=\"color\">Example color</label> \n <input type=\"color\" id=\"color\" />\n </p>\n <p>\n <label for=\"output\">Example output</label> \n <output name=\"result\" id=\"output\">100</output>\n </p>\n <p>\n <button type=\"submit\">Button submit</button> \n <input type=\"submit\" value=\"Input submit button\" /> \n <input type=\"reset\" value=\"Input reset button\" /> \n <input type=\"button\" value=\"Input button\" />\n </p>\n <p>\n <button type=\"submit\" disabled>Button submit</button> \n <input type=\"submit\" value=\"Input submit button\" disabled /> \n <input type=\"reset\" value=\"Input reset button\" disabled /> \n <input type=\"button\" value=\"Input button\" disabled />\n </p>\n </fieldset>\n</form>\n\n## Misc elements\n\n### Address\n\nThe `<address>` element is updated to reset the browser default `font-style` from `italic` to `normal`. `line-height` is also now inherited, and `margin-bottom: 1rem` has been added. `<address>`s are for presenting contact information for the nearest ancestor (or an entire body of work). Preserve formatting by ending lines with `<br/>`.\n\n<div class=\"baseline-example\">\n <address>\n <strong>Twitter, Inc.</strong><br/>\n 1355 Market St, Suite 900<br/>\n San Francisco, CA 94103<br/>\n <abbr title=\"Phone\">P:</abbr> (123) 456-7890\n </address>\n\n <address>\n <strong>Full Name</strong><br/>\n <a href=\"mailto:first.last@example.com\">first.last@example.com</a>\n </address>\n</div>\n\n### Blockquote\n\nThe default `margin` on blockquotes is `1em 40px`, so we reset that to `0 0 1rem` for something more consistent with other elements.\n\n<div class=\"baseline-example\">\n <blockquote class=\"blockquote\">\n <p>A well-known quote, contained in a blockquote element.</p>\n </blockquote>\n <p>Someone famous in <cite title=\"Source Title\">Source Title</cite></p>\n</div>\n\n### Inline elements\n\nThe `<abbr>` element receives basic styling to make it stand out amongst paragraph text.\n\n<div class=\"baseline-example\">\n Nulla <abbr title=\"attribute\">attr</abbr> vitae elit libero, a pharetra augue.\n</div>\n\n### Summary\n\nThe default `cursor` on summary is `text`, so we reset that to `pointer` to convey that the element can be interacted with by clicking on it.\n\n<div class=\"baseline-example\">\n <details>\n <summary>Some details</summary>\n <p>More info about the details.</p>\n </details>\n\n <details open>\n <summary>Even more details</summary>\n <p>Here are even more details about the details.</p>\n </details>\n</div>\n\n## HTML5 `[hidden]` attribute\n\nHTML5 adds [a new global attribute named `[hidden]`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/hidden), which is styled as `display: none` by default. Borrowing an idea from [PureCSS](https://purecss.io/), we improve upon this default by making `[hidden] { display: none !important; }` to help prevent its `display` from getting accidentally overridden.\n\n```html\n<input type=\"text\" hidden>\n```\n",
|
|
13
|
+
"title": "Style Guide/Baseline CSS",
|
|
14
|
+
"description": "## Usage",
|
|
15
|
+
"filePath": "website/style-guide/3.6-baselinecss.stories.mdx"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"frontmatter": {},
|
|
19
|
+
"content": "import { Meta, Story } from '@storybook/addon-docs/blocks';\nimport Icons from '@chotot/clad-ui/storybook/Icons';\nimport SystemIcons from '@chotot/clad-ui/storybook/SystemIcons';\nimport ShapedIcon from '@chotot/clad-ui/components/ShapeIcon/ShapeIcon';\nimport {Location} from '@chotot/icons';\n\n<Meta title=\"Style Guide/Iconography\" parameters={{ previewTabs: { canvas: { hidden: true } } }} />\n\n<Story name=\"Intro\">\n <div id=\"intro\"></div>\n</Story>\n\n# Iconography\n\nClad UI icon is a React component that wrap an inline SVG.\n\nThe inline SVG has attributes of `width=\"1em\" height=\"1em\"`, that means it will inherit from parent's font size or you can change its size by specifying CSS `font-size` property.\n\nClad UI icons are classified into 2 types of icons: **monochrome** and **color**. With **monochrome** icons, developer can specify its color with the CSS **color** property.\n\nTo add new icon, refer to [Icon Development Guide](?path=/docs/style-guide-iconography--development-guide) below.\n\nIf you wish to have icons framed with circle <ShapedIcon bg=\"primary\" color=\"white\" radius=\"circle\" size=\"sm\"><Location /></ShapedIcon>\nor rounded square <ShapedIcon bg=\"primary\" color=\"white\" radius=\"sm\" size=\"sm\"><Location /></ShapedIcon>, check out [ShapeIcon component](?path=/docs/components-shapeicon--overview)\n\n```jsx\nimport { sx } from '@chotot/clad-ui/utils';\nimport { Download } from '@chotot/icons';\n\nconst buttonClass = css`\n ${sx({\n color: 'primary',\n fontSize: 'sm',\n })}\n`;\n\nexport default function DownloadButton() {\n return (\n <button className={buttonClass}>\n <Download /> Download\n </button>\n );\n}\n```\n\n## System Icons\n\nNaming: System Icon + \"Filled\" (optional)\n\n{/* Renaming icons:\n ArrowDownB -> ChevronDownFilled\n ArrowLeft -> ChevronLeft\n ArrowRight -> ChevronRight\n Back -> ArrowLeft\n BinOutline -> TrashBin\n Bookmark -> BookmarkFilled\n BookmarkOutline -> Bookmark\n BoyFace -> BoyFaceFilled\n BoyFaceOutline -> BoyFace\n CallOutline -> Phone\n CardPayment -> CardPaymentFilled\n EditAd -> Edit\n Ellipsis -> EllipsisFilled\n EllipsisOutline -> Ellipsis\n FacebookOutline -> Facebook\n Gift -> GiftFilled\n GiftOutline -> Gift\n Heart -> HeartFilled\n HeartOutline -> Heart\n HideAd -> Hide\n House -> HouseFilled\n HouseOutline -> House\n Impression -> ImpressionFilled\n Info -> InfoFilled\n Location -> LocationFilled\n LocationOutline -> Location\n MailOutline -> Mail\n PaymentInfo -> PaymentInfoFilled\n PhoneOutline -> Phone\n Selected -> CircleCheckFilled\n Shop -> ShopFilled\n ShopOutline -> Shop */}\n\n\n<Story name=\"SystemIcons\">\n <SystemIcons />\n</Story>\n\n# Icon Development Guide\n\n<Story name=\"Development Guide\">\n <div id=\"development-guide\"></div>\n</Story>\n\nSteps to add a new icon to the collection:\n\n1. Extract or receive the icon from designer in SVG format.\n2. Use [SVGOMG](https://jakearchibald.github.io/svgomg/) to optimize the markups of the icon\n3. Store it in `assets/icons` folder, and name it properly with snake case format. (Icon's name is unique in @chotot/clad-ui's icon collection)\n4. Modify icon mark up with additional metadata:\n - Classify icon as `monochrome` or `color` and supplement `data-type` attribute to the `<svg>` tag.\n Example: `<svg data-type=\"monochrome\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 30 30\">`\n - For monochrome icons, normalize the fill/stroke color of the icon with **#222** or **currentColor** value. (`#222` will be replaced with `currentColor` during SVG-to-React compilation).\n - For the icon to be normalized and scaled with **font-size**, replace SVG's `width` and `height` (if any) with `viewBox`\n5. Execute following npm script `pnpm build-icons` from terminal. Under the hood, npx will fetch and execute the [**svgr**](https://react-svgr.com/) CLI to convert all svg in `assets/icons` folder to `icons` as React components.\n",
|
|
20
|
+
"title": "Style Guide/Iconography",
|
|
21
|
+
"description": "Clad UI icon is a React component that wrap an inline SVG.",
|
|
22
|
+
"filePath": "website/style-guide/3.5-icons.stories.mdx"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"frontmatter": {},
|
|
26
|
+
"content": "import { Meta, Story, Canvas } from '@storybook/addon-docs/blocks';\nimport Square from '@chotot/clad-ui/storybook/Square';\nimport Bar from '@chotot/clad-ui/storybook/Bar';\nimport BorderRadius from '@chotot/clad-ui/storybook/BorderRadius';\nimport BorderWidth from '@chotot/clad-ui/storybook/BorderWidth';\nimport Shadow from '@chotot/clad-ui/storybook/Shadow';\nimport Gradient from '@chotot/clad-ui/storybook/Gradient';\nimport Transition from '@chotot/clad-ui/storybook/Transition';\n\n<Meta\n title=\"Style Guide/Sizes & Scales\"\n parameters={{ previewTabs: { canvas: { hidden: true } } }}\n/>\n\n<Story name=\"Scale Naming\">\n <div id=\"scale-naming\"></div>\n</Story>\n\n## Scale Naming\n\nWhen it comes to name the different sizes and weights in scales, we'll use following naming convention:\n\n- ...\n- **xxs**\n- **xs** (extra small)\n- **sm** (small)\n- **md** (medium)\n- **lg** (large)\n- **xl** (extra large)\n- **xxl**\n- **xxxl**\n- ...\n\n## Spacing\n\n```\ntheme.space.[ none | xxxs | xxs | xs | sm | md | mdl | lg | xl | xxl | xxxl | xxxxl | xxxxxl ];\n```\n\nUse spacings for gutters, margins, and paddings. Don't use it for border width, border radius, icon size, font size, or line height. Use the dedicated theme properties instead.\n\n<Canvas>\n <Story name=\"Spacing\">\n <Square size=\"xxxs\" />\n <Square size=\"xxs\" />\n <Square size=\"xs\" />\n <Square size=\"sm\" />\n <Square size=\"md\" />\n <Square size=\"mdl\" />\n <Square size=\"lg\" />\n <Square size=\"xl\" />\n <Square size=\"xxl\" />\n <Square size=\"xxxl\" />\n <Square size=\"xxxxl\" />\n <Square size=\"xxxxxl\" />\n </Story>\n</Canvas>\n\n## Sizes\n\n```\n// absolute scale steps\ntheme.sizes.[ xxxs | xxs | xs | sm | md | lg | lxl | xl | xxl | xxxl | xxxxl | xxxxxl | buttonMaxWidth | $sm | $md | $lg | $xl ]\n\n// percentage and relative to screen size\ntheme.sizes.[ quarter | third | half | twoThird | threeQuarter | full | vW | vH ];\n```\n\nUse sizes for width, height, min-width, max-width, min-height and max-height.\n\n<Canvas>\n <Story name=\"Sizes\">\n <Bar size=\"xxxs\" />\n <Bar size=\"xxs\" />\n <Bar size=\"xs\" />\n <Bar size=\"sm\" />\n <Bar size=\"md\" />\n <Bar size=\"lg\" />\n <Bar size=\"lxl\" />\n <Bar size=\"xl\" />\n <Bar size=\"xxl\" />\n <Bar size=\"xxxl\" />\n <Bar size=\"xxxxl\" />\n <Bar size=\"xxxxxl\" />\n <Bar size=\"buttonMaxWidth\" />\n <Bar size=\"$sm\" />\n <Bar size=\"$md\" />\n <Bar size=\"$lg\" />\n <Bar size=\"$xl\" />\n <Bar size=\"quarter\" />\n <Bar size=\"third\" />\n <Bar size=\"half\" />\n <Bar size=\"twoThird\" />\n <Bar size=\"threeQuarter\" />\n <Bar size=\"full\" />\n <Bar size=\"vW\" />\n <Bar size=\"vH\" />\n </Story>\n</Canvas>\n\n## Line / Border Widths\n\n```\ntheme.borderWidths.[ none | sm | md | lg | xl ];\n```\n\n<Canvas>\n <Story name=\"Border Widths\">\n <BorderWidth size=\"none\" />\n <BorderWidth size=\"sm\" />\n <BorderWidth size=\"md\" />\n <BorderWidth size=\"lg\" />\n <BorderWidth size=\"xl\" />\n </Story>\n</Canvas>\n\n## Border Radius\n\n```\ntheme.radii.[ none | xs | sm | md | lg | xl | pill | circle ];\n```\n\n<Canvas>\n <Story name=\"Border Radius\">\n <BorderRadius size=\"none\" desc=\"No border radius\" />\n <BorderRadius size=\"xs\" desc=\"Used for images, thumbnails\" />\n <BorderRadius size=\"sm\" desc=\"Used for buttons\" />\n <BorderRadius size=\"md\" desc=\"This step is unused\" />\n <BorderRadius size=\"lg\" desc=\"This step is unused\" />\n <BorderRadius size=\"xl\" desc=\"Used for C2C home page category thumbnails\" />\n <BorderRadius size=\"pill\" desc=\"Used for pill buttons\" />\n <BorderRadius size=\"circle\" desc=\"Used for icons, circle icon buttons\" />\n </Story>\n</Canvas>\n\n## Shadows\n\n```\ntheme.shadows.[ none | md | lg ];\n```\n\n<Canvas>\n <Story name=\"Shadows\">\n <Shadow size=\"none\" />\n <Shadow size=\"md\" />\n <Shadow size=\"lg\" />\n </Story>\n</Canvas>\n\n## Gradients\n\n```\ntheme.gradient.[ toDark | toLight ];\n```\n\n<Canvas>\n <Story name=\"Gradients\">\n <Gradient name=\"toDark\" />\n <Gradient name=\"toLight\" darkBG />\n </Story>\n</Canvas>\n\n## Durations\n\n```js\ntheme.durations.[ xxxs | xxs | xs | sm | md | lg | xl | xxl | xxxl | xxxxl ];\n```\n\n**Note**: `duration` is not (yet) a standard System UI Theme Specification, therefore, it will not work with `sx()` helper. (Access the tokens via `theme` object instead).\n\n<Canvas>\n <Story name=\"Durations\">\n <Transition duration=\"xxxs\" />\n <Transition duration=\"xxs\" />\n <Transition duration=\"xs\" />\n <Transition duration=\"sm\" />\n <Transition duration=\"md\" />\n <Transition duration=\"lg\" />\n <Transition duration=\"xl\" />\n <Transition duration=\"xxl\" />\n <Transition duration=\"xxxl\" />\n <Transition duration=\"xxxxl\" />\n </Story>\n</Canvas>\n",
|
|
27
|
+
"title": "Style Guide/Sizes & Scales",
|
|
28
|
+
"description": "When it comes to name the different sizes and weights in scales, we'll use following naming convention:",
|
|
29
|
+
"filePath": "website/style-guide/3.4-scales-sizes.stories.mdx"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"frontmatter": {},
|
|
33
|
+
"content": "import { Meta, Story, Canvas, Source } from '@storybook/addon-docs/blocks';\nimport Type from '@chotot/clad-ui/storybook/Type';\nimport jsonStringify from '../utils/jsonStringify';\nimport theme from '@chotot/clad-ui/theme';\nimport TypographyMapping from '@chotot/clad-ui/storybook/TypographyMapping';\n\n<Meta title=\"Style Guide/Typography\" parameters={{ previewTabs: { canvas: { hidden: true } } }} />\n\n# Typography\n\nIn design system v3, Chotot Design System uses **Reddit Sans** as the primary font across all platforms:\n\n- Web: **Reddit Sans**, sans-serif;\n- Mobile App\n - iOS: **Reddit Sans**\n - Android: **Reddit Sans**\n\n> **Note:** Previous versions used system fonts like Arial, Helvetica, and Roboto based on respective platforms.\n\n## Anatomy [`🎨 Figma Spec`](https://www.figma.com/design/7LqhWWih6NtRnk0NddrgAb/v2.0-CHOTOT-Design-System?node-id=1-2&p=f&t=BWO4SFUVtcEccNEx-0)\n\nThe typography includes two main parts:\n\n### 1. Levels (Size & Weight)\n\nType styles are defined based on five levels:\n\n- **Display**:\n Used only on landing pages or sale pages, reserved for short, important text or numerals.\n- **Header**:\n Used on product pages to separate content into sections and establish a clear hierarchy of information.\n- **Label**:\n Also used on product pages to separate content into sections and provide a clear hierarchy.\n- **Body**:\n For longer blocks of text, primarily used for text-heavy content.\n- **Note**:\n A short phrase or sentence that provides context or information about a specific block of text.\n\n### 2. Function\n\nType styles are also categorized based on four functions:\n\n- **Page**:\n Ideally used for ad titles, prices, and key information within a page.\n- **Section**:\n Suited for section headers, section descriptions, and often the most dominant type styles on the page.\n- **Caption**:\n Ideal for image captions, disclaimers, and minor information.\n- **Annotation**:\n Designed for input field labels, navigation labels, and help text.\n\n## Hierarchy rules\n\nA clear, logical information architecture enhances the readability and scannability of an interface.\n\n<img src=\"typography-hierarchy.png\" />\n\n## Typography Tokens (`theme.typo`)\n\n**@chotot/clad-ui `1.4.2+`** introduce a set of new **Typography Tokens** at `theme.typo[level][function]` keys. Each key is a JS object defining collectively CSS properties for a typography rule. Next section will show all the available tokens with their values.\n\nCurrent `typo` token object:\n\n<Source language=\"js\" code={'theme.typo = ' + jsonStringify(theme.typo, 2 )}></Source>\n\n\n## Typography Components\n\nThis list includes all typography styles, along with their names, illustrations, and key styling attributes. Note that, in each level, not all functions are available.\n\n> Note: 1rem = 16px\n\n<Story name=\"Theme Tokens\">\n <div id=\"theme-tokens\"></div>\n <TypographyMapping />\n</Story>\n\n\n## Usage Example\n\n### Reddit Sans is a variable font and hosted on Google Fonts\n\nTo use Reddit Sans, add following `<link>` tag to the application `<head>` section:\n\n```html\n<link rel=\"preconnect\" href=\"https://fonts.googleapis.com\">\n<link rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin>\n<link href=\"https://fonts.googleapis.com/css2?family=Reddit+Sans:ital,wght@0,200..900;1,200..900&display=swap\" rel=\"stylesheet\">\n```\n\n### Use Typography tokens in React + Linaria applications\n\n```js\nimport { css } from '@linaria/core';\nimport theme from '@chotot/clad-ui/theme';\n// built-in Typography components\nimport { DisplayPage } from '@chotot/clad-ui/typography';\n// typography settings in theme\nconst { typo } = theme;\n\n// use Linaria's styled object to apply all typography CSS config at once (font, fontWeight, etc.)\nconst content = css`\n ${typo.body.page}\n`;\n\nconst Home = () => {\n return (\n <div>\n <DisplayPage as=\"h1\">Trang chủ</DisplayPage>\n <p className={content}>\n Chotot.com là trang web mua bán trực tuyến hàng đầu tại Việt Nam với hàng triệu sản phẩm từ mọi lĩnh vực.\n </p>\n {/* Other content */}\n </div>\n );\n};\n```\n",
|
|
34
|
+
"title": "Style Guide/Typography",
|
|
35
|
+
"description": "In design system v3, Chotot Design System uses **Reddit Sans** as the primary font across all platforms:",
|
|
36
|
+
"filePath": "website/style-guide/3.3-typography.stories.mdx"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"frontmatter": {},
|
|
40
|
+
"content": "import { Meta } from '@storybook/addon-docs/blocks';\nimport Swatch from '@chotot/clad-ui/storybook/Swatch';\nimport ColorClasses from '@chotot/clad-ui/storybook/ColorClass';\nimport ColorFoundation from '@chotot/clad-ui/storybook/ColorFoundation';\nimport ColorFoundationList from '@chotot/clad-ui/storybook/ColorFoundationList';\n\n<Meta title=\"Style Guide/Colors\" parameters={{ previewTabs: { canvas: { hidden: true } } }} />\n\n# Colors\n\nIt is encouraged to use **semantic** color names instead of the primitive tokens. Please help expand the **semantic colors** where they make sense.\n\n```js\nimport { css } from '@linaria/core';\nimport { sx } from '@chotot/clad-ui/utils';\nimport theme from '@chotot/clad-ui/theme';\n\n// destructured object shortcuts\nconst { colors } = theme;\n\nconst buttonStyle = css`\n background-color: ${colors.secondary};\n color: ${colors.gray900};\n`;\n\n// theme-aware helper\nconst swatchStyle = css`\n ${sx({\n backgroundColor: 'gray50',\n color: 'text',\n })}\n`;\n```\n\n## Full Color Palette\n\n<ColorClasses />\n\n## Semantic colors\n\n{/* TODO: Find a way to extract jsdoc from theme's properties and use as description */}\n\n### UI\n\n<ColorFoundation\n title=\"brand\"\n color=\"yellow\"\n colorWeight=\"200\"\n description=\"Cho Tot's brand color\"\n/>\n<ColorFoundation\n title=\"primary\"\n color=\"orange\"\n colorWeight=\"300\"\n description=\"A primary color is the color displayed most frequently across Cho Tot's screens and components.\"\n/>\n<ColorFoundation\n title=\"secondary\"\n color=\"green\"\n colorWeight=\"400\"\n description=\"A secondary color provides more ways to accent and distinguish our product. Having a secondary color is optional, and should be applied sparingly to accent select parts of Cho Tot’s UI.\"\n/>\n\n### Informative\n\n<ColorFoundation\n title=\"critical\"\n color=\"red\"\n colorWeight=\"500\"\n description=\"Super important. You need to see this.\"\n/>\n<ColorFoundation\n title=\"caution\"\n color=\"yellow\"\n colorWeight=\"200\"\n description=\"You should be aware something is happening or mid-way through a process. Could be a risk or an item that needs to be acted upon.\"\n/>\n<ColorFoundation\n title=\"info\"\n color=\"blue\"\n colorWeight=\"400\"\n description=\"Guidance & advice. Generally from the UI or business. Functional, calm and non urgent.\"\n/>\n<ColorFoundation\n title=\"positive\"\n color=\"green\"\n colorWeight=\"400\"\n description=\"Good vibes & new things! Wants to get the user to act on something or be aware something good happened.\"\n/>\n\n## Color Alias\n\n<ColorFoundationList />\n\n## ⛔ Color 1.0 Fallback\n\nSince @chotot/clad-ui@1.5+, we don't support the old color scheme 1.0 (`red1`, `red2`...) anymore.\n\n\n> a11y: Accessibility\n",
|
|
41
|
+
"title": "Style Guide/Colors",
|
|
42
|
+
"description": "It is encouraged to use **semantic** color names instead of the primitive tokens. Please help expand the **semantic colors** where they make sense.",
|
|
43
|
+
"filePath": "website/style-guide/3.2-colors.stories.mdx"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"frontmatter": {},
|
|
47
|
+
"content": "import { Meta } from '@storybook/addon-docs/blocks';\nimport jsonStringify from '../utils/jsonStringify';\nimport theme from '@chotot/clad-ui/theme';\n\n<Meta title=\"Style Guide/Intro\" parameters={{ previewTabs: { canvas: { hidden: true } } }} />\n\n# What are Tokens?\n\n> From: https://design.workday.com/tokens\n\nTokens are the smallest pieces of our Design System. Their primary function is to store UI information that allows for building components and patterns at a sustainable scale while securing consistency across our platforms.\n\nBased on this definition, 2 key metrics help us understand and define tokens:\n\n1. A token is an immutable element that requires a well-defined and justified adoption and/or modification process.\n\n2. A token is the raw material or tool we use to build more complex elements like components and patterns.\n\n## Tokens and Theme Specification\n\nClad UI design tokens are defined in a format so-called [System UI Theme Specification](https://system-ui.com/theme/). The theme is a JavaScript object with conventional theme keys that store design system style values, scales and other primitive design tokens.\n\nSee [full extract of Chotot's theme object](#current-chotot-theme-object) below.\n\n## Theme Key Reference\n\nThe following is a list of theme object keys and their corresponding CSS properties.\nThis list may be non-exhaustive.\n\n| Theme Key | CSS Properties |\n| ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `space` | `margin`, `margin-top`, `margin-right`, `margin-bottom`, `margin-left`, `padding`, `padding-top`, `padding-right`, `padding-bottom`, `padding-left`, `grid-gap`, `grid-column-gap`, `grid-row-gap` |\n| `fontSizes` | `font-size` |\n| `colors` | `color`, `background-color`, `border-color` |\n| `fonts` | `font-family` |\n| `fontWeights` | `font-weight` |\n| `lineHeights` | `line-height` |\n| `letterSpacings` | `letter-spacing` |\n| `sizes` | `width`, `height`, `min-width`, `max-width`, `min-height`, `max-height` |\n| `borders` | `border`, `border-top`, `border-right`, `border-bottom`, `border-left` |\n| `borderWidths` | `border-width` |\n| `borderStyles` | `border-style` |\n| `radii` | `border-radius` |\n| `shadows` | `box-shadow`, `text-shadow` |\n| `zIndices` | `z-index`\n\n## Current Chotot Theme Object\n\nBelow is the static extract of Chotot's theme object which will be explained and illustrated in the next sections:\n\n<pre><code language=\"json\">{'theme = ' + jsonStringify(theme, 2, ['shadows'])}</code></pre>\n",
|
|
48
|
+
"title": "Style Guide/Intro",
|
|
49
|
+
"description": "> From: https://design.workday.com/tokens",
|
|
50
|
+
"filePath": "website/style-guide/3.1-tokens-intro.stories.mdx"
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"about": [
|
|
54
|
+
{
|
|
55
|
+
"frontmatter": {},
|
|
56
|
+
"content": "import { Meta } from '@storybook/addon-docs/blocks';\nimport Grid from '@chotot/clad-ui/components/Grid/Grid';\nimport Col from '@chotot/clad-ui/components/Grid/Col';\nimport Box from '@chotot/clad-ui/components/Box/Box';\nimport Member from '@chotot/clad-ui/storybook/Member';\n\n<Meta title=\"Overview/About the Project\" parameters={{ previewTabs: { canvas: { hidden: true } } }} />\n<div style={{margin: '-4rem auto', height: '100vh'}}>\n <iframe id=\"iframe-wiki\" src=\"https://701search.atlassian.net/wiki/external/NDM2NDVlNjI4OGUzNDc0Yzk3MTk0OWQzOGFmZjdhZTI\" frameborder=\"0\" width=\"100%\" height=\"100%\" ></iframe>\n</div>\n\n",
|
|
57
|
+
"title": "Overview/About the Project",
|
|
58
|
+
"filePath": "website/about/2.6-about-project.stories.mdx"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"frontmatter": {},
|
|
62
|
+
"content": "import { Meta } from '@storybook/addon-docs/blocks';\n\n<Meta title=\"Overview/Props Index\" parameters={{ previewTabs: { canvas: { hidden: true } } }} />\n\n# Props Index\n\nBecause of history reasons, we did not standardize prop name at first which ended up multiple prop names\nof the same usage. Below is the list of all prop names and their standadized prop name.\n\nFor legacy compatibility, we will not change the derived prop names (at least for @chotot/clad-ui 1.0) but\nfor any new components added, they should strictly follow standardized prop names only.\n\n| Standardize Prop Name | Prop Name | Type | Usage | Component |\n| ------------------------- | ---------------------------------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `onClose` | `onClose` | function | Callback when component is closed | Announcer, Chip, Snack, Drawer, Popup, LegacyDialog, LegacyPopup |\n| `onButtonClick` | `onButtonClick` , `onActionClick` | function | Callback when button is clicked | Announcer, EmptyState, LegacyDialog, LegacyPopup, Snack |\n| `onClick` | `onClick` | function | Callback when component is clicked | Announcer, Button, Chip, Dropdown, RowItem, Tab |\n| `onChange` | `onChange` | function | Callback when value is changed | Checkbox, Input, RadioButton, RowItem, Slider, Tabs , ToggleSwitch, MultiSearchDropdown, TextArea, SearchInput, TagCloud |\n| `onFormatChange` | `onFormatChange` | function | Callback when value is changed, return formatted value | CurrencyInput |\n| `onKeyDown` | `onKeyDown` | function | Callback when key down | Input |\n| `onKeyUp` | `onKeyUp` | function | Callback when key up | Input |\n| `onBlur` | `onBlur` | function | Callback when blur | Input, Dropdown, MultiSearchDropdown, TextArea, SearchInput |\n| `onFocus` | `onFocus` | function | Callback when focus | Input, Dropdown, MultiSearchDropdown, TextArea, SearchInput |\n| `onRightIconClick` | `onRightIconClick` | function | Callback when right icon is clicked | LegacyPopup |\n| `onInput` | `onInput` | function | Callback when user types in the search text field | MultiSearchDropdown, SearchInput |\n| `onRemoveOption` | `onRemoveOption` | function | Callback when remove option | MultiSearchDropdown |\n| `onClearData` | `onClearData` | function | Callback when remove input content with clear icon | MultiSearchDropdown |\n| `onPrimaryButtonClick` | `onPrimaryButtonClick` | function | Callback when main button is clicked | Drawer, Popup |\n| `onSecondaryButtonClick` | `onSecondaryButtonClick` | function | Callback when secondary button is clicked | Drawer, Popup |\n| `onOptionalButtonClick` | `onOptionalBtnClick` | function | Callback when optional button is clicked | Drawer |\n| `onSelect` | `onSelect` | function | Callback when user select option | MultiSearchDropdown, SearchInput |\n| `btnLabel` | `btnLabel`, `buttonLabel`, `actionLabel` | function | Button label | Announcer, EmptyState, Snack |\n| `primaryBtnLabel` | `primaryBtnLabel` | function | Button label | Drawer, Popup |\n| `secondaryBtnLabel` | `secondaryBtnLabel` | function | Button label | Drawer, Popup |\n| `optionalBtnLabel` | `optionalBtnLabel` | function | Button label | Drawer, Popup |\n| `label` | `label` | string | Label | Announcer, Badge, Checkbox, CurrencyInput, Dropdown, Input, RadioButton, Tab, TextArea, Snack |\n| `title` | `title` | string | Title | Announcer, Drawer, EmptyState, LegacyPopup, LegacyDialog, Popup |\n| `name` | `name` | string | Name | Checkbox, CurrencyInput, Dropdown, Input, RadioButton, RowItem, ToggleSwitch, MultiSearchDropdown, TextArea, SearchInput |\n| `position` | `position` | string | Position | Badge |\n| `btnRowPosition` | `btnRowPosition` | string | Button Group Position | Drawer, Popup |\n| `btnGroupDirection` | `btnGroupDirection` | string | Button Group Direction | Popup |\n| `justifyContent` | `justifyContent` | string | `justify-content` | Box |\n| `placement` | `placement` | string | Preferred placement | Tooltip |\n| `backgroundColor` | `backgroundColor`, `bg` | string | `background-color` | Badge, Box, ShapeIcon |\n| `backgroundImage` | `backgroundImage` | string | `background-image` | Box |\n| `borderColor` | `borderColor` | string | `border-color` | Box |\n| `color` | `primaryColor` , `color` | string | Primary color | Drawer, Popup, Box, Button, Checkbox, RadioButton, ShapeIcon, ToggleSwitch |\n| `padding` | `padding` | string | `padding` | Box, LegacyPopup |\n| `paddingx` | `paddingx` | string | `padding-x` | Box |\n| `paddingy` | `paddingy` | string | `padding-y` | Box |\n| `borderWidth` | `borderWidth` | string | `border-width` | Box |\n| `border` | `border` | string | `border` | RowItem |\n| `textAlign` | `textAlign` | string | `text-align` | Box |\n| `align` | `alignItems`, `align` | string | `algin-items` | Box , Col, Grid |\n| `radius` | `borderRadius`, `radius` | string | `border-radius` | Badge, Box, Button, ShapeIcon |\n| `style` | `style` | any | Additional inline style object | Box |\n| `weight` | `weight` | string | `font-weight` of label | Button |\n| `boxShadow` | `boxShadow` | string | `box-shadow` | Box |\n| `variant` | `variant` | string | Display behavior | Button, Tab , Tooltip, SearchInput |\n| `width` | `width` | string | `width` | Box, CurrencyInput, Dropdown, Grid, Input, RadioButton, Slider, MultiSearchDropdown, TextArea, SearchInput |\n| `maxWidth` | `maxWidth` | string | `max-width` | Box |\n| `height` | `height` | string | `height` | Box |\n| `inputWidth` | `inputWidth` | string | Width of input field | Slider |\n| `minWidth` | `minWidth` | string | min-width | Chip |\n| `size` | `size` | string | Size | Badge, Button, Chip, RowItem, ToggleSwitch |\n| `min` | `min` | string | Minumum value | Slider |\n| `max` | `max` | string | Maximum value | Slider |\n| `desktopSize` | `desktopSize` | string | `max-width` on desktop | Snack, LegacyDialog, LegacyPopup |\n| `mobileSize` | `mobileSize` | string | `max-height` on mobile | LegacyPopup |\n| `characterLimit` | `characterLimit` | number | Maximum number of characters allowed | Input, TextArea |\n| `maxDigits` | `maxDigits` | number | Maximum number of characters allowed | CurrencyInput |\n| `decimalsLimit` | `decimalsLimit` | number | Limit length of decimals allowed | CurrencyInput |\n| `menuMaxHeight` | `menuMaxHeight` | string | Input menu `max-height` | MultiSearchDropdown, SearchInput |\n| `maxSelection` | `maxSelection` | number | Maximum number of options | TagCloud |\n| `lines` | `lines` | number | Number of lines | TextArea |\n| `type` | `type` | string | Type | Announcer, Input, RowItem, Slider, EmptyState, SearchInput |\n| `as` | `as` | string | Element or component to be rendered as | Box, Button, Chip, ShapeIcon, Tab |\n| `className` | `extraClasses`, `className` | string | className | Button, Box, Breadcrumbs, Checkbox, Chip, Dropdown, Col, Grid, RadioButton, Tab, Drawer, LegacyDialog, Popup, TagCloud |\n| `id` | `id` | string | id | Checkbox, CurrencyInput, Dropdown, Input, RadioButton, Slider, Tab, TextArea, ToggleSwitch, MultiSearchDropdown, SearchInput |\n| `status` | `status` | string | Status | CurrencyInput, Dropdown, Input, TextArea, InputGroup, SearchInput, TagCloud |\n| `text` | `text` | string | Content | CurrencyInput, Dropdown, Input, TextArea, Tooltip, InputGroup, MultiSearchDropdown, SearchInput, TagCloud |\n| `dangerousHtml` | `dangerousHtml` | string | A replacement for `children`, rendered via dangerouslySetInnerHTML | Announcer, Box, Tooltip |\n| `children` | `children` | string, any | String or element that the component wraps | Announcer, Badge, Box, Breadcrumbs, Button, Chip, Col, Grid, RowItem, ShapeIcon, Snack, Tab, Tooltip, Drawer, Popup, LegacyDialog, LegacyPopup |\n| `options` | `options` | Array | Options array to provide for the dropdown | Dropdown, MultiSearchDropdown, SearchInput, TagCloud |\n| `value` | `value` | number | Value | Checkbox, Chip, CurrencyInput, Dropdown, Input, RadioButton, RowItem, Slider, Tab, TextArea, ToggleSwitch, MultiSearchDropdown, SearchInput, TagCloud |\n| `placeholder` | `placeholder` | string | Placeholder | TextArea |\n| `description` | `description` | string | Custom description | EmptyState |\n| `href` | `href` | string | Href | ButtonLink, Chip, Tab |\n| `helptext` | `helptext` | string | Prompt a helptext below input | CurrencyInput, Dropdown, Input, TextArea, InputGroup, SearchInput, TagCloud |\n| `inputRef` | `inputRef` | any | Input ref | CurrencyInput, Dropdown, Input, TextArea, MultiSearchDropdown, SearchInput |\n| `tagCloudRef` | `tagCloudRef` | any | Tag cloud ref | TagCloud |\n| `separator` | `separator` | string | Separator between thousand, million and billion | CurrencyInput |\n| `decimalSeparator` | `decimalSeparator` | string | Separator between integer part and fractional part of value | CurrencyInput |\n| `span` | `span` | Cols | Column span | Col |\n| `offset` | `offset` | number | Increase the left margin of a column by span | Col |\n| `order` | `order` | any | Order in grid | Col, RowItem |\n| `tooltip` | `tooltip` | string | Show a icon that contains tooltip | Input, SearchInput |\n| `step` | `step` | number | Step size increasement | Slider |\n| `unit` | `unit` | string | Unit | Slider |\n| `suffix` | `suffix` | string | Suffix. eg: đ, $ or £,... | CurrencyInput |\n| `autoHideDuration` | `autoHideDuration` | string | Delay time before disappearing | Snack |\n| `icon` | `icon` | boolean, any | Custom Icon | Button, RowItem, Tab |\n| `closeIcon` | `closeIcon` | any | Custom close icon | LegacyDialog, LegacyPopup, Drawer |\n| `rightIcon` | `rightIcon` | any | Popup header right icon | LegacyPopup |\n| `mainIcon` | `mainIcon` | any | Custom main icon | LegacyDialog |\n| `indicator` | `indicator` | any | Indicator element | Tab |\n| `resize` | `resize` | string | Allow user to resize TextArea | TextArea |\n| `inputMode` | `inputMode` | string | Enumerated attribute that hints at the type of data that might be entered by the user | Input, TextArea, SearchInput |\n| `delayEnter` | `delayEnter` | string | Delay time (ms) before Tooltip appears | Tooltip |\n| `delayLeave` | `delayLeave` | string | Delay time (ms) before Tooltip disappears | Tooltip |\n| `arrowOffset` | `arrowOffset` | string | Minimal distance between arrow and Tooltip edges | Tooltip |\n| `triggerOffset` | `triggerOffset` | string | Distance between Tooltip and trigger | Tooltip |\n| `zIndex` | `zIndex` | string | `z-index` | Tooltip |\n| `tabIndex` | `tabIndex` | string | TabIndex html attribute | Tab |\n| `emptyString` | `emptyString` | string | Empty string on no options | MultiSearchDropdown |\n| `coverImage` | `coverImage` | string | Custom coverImage url | EmptyState |\n| `imgSize` | `imgSize` | string | Header Image Size/Hide | Popup |\n| `fadeDuration` | `fadeDuration` | string | Time of fade animation | Tooltip |\n| `open` | `open` | boolean | Whether this component is open or not | Announcer, Drawer, Popup, LegacyDialog, LegacyPopup |\n| `isShow` | `isShow` | boolean | Whether this component show or not | Breadcrumbs |\n| `active` | `active` | boolean | Whether this component is active/selected or not | Chip, Tab |\n| `disabled` | `disabled` | boolean | Whether this component is disabled or not | Button, Checkbox, Chip, CurrencyInput, Dropdown, Input, RadioButton, Slider, Tab, TextArea, ToggleSwitch, MultiSearchDropdown, SearchInput |\n| `required` | `required` | boolean | Whether this component is required or not | CurrencyInput, Dropdown, Input, TextArea, SearchInput, TagCloud |\n| `haveClose` | `haveClose` | boolean | Whether this component has close button or not | Snack, Popup |\n| `allowClear` | `allowClear` | boolean | If allow to remove input content with clear icon | Input, SearchInput |\n| `showPassword` | `showPassword` | boolean | Show entered password | Input |\n| `compact` | `compact` | boolean | Turn Announcer to single line. Useful for short announcement. | Announcer |\n| `isResizeableOnFocus` | `isResizeableOnFocus` | boolean | Resizeable on focus event | TextArea |\n| `checked` | `checked` | boolean | Whether this component is checked initially or not | Checkbox, RadioButton, RowItem, ToggleSwitch |\n| `inverted` | `inverted` | boolean | Inverted position of icon and radio/checkbox | RowItem |\n| `manual` | `manual` | boolean | Turn off Tooltip's ability to switch automatically to a placement that is more visible on the screen | Tooltip |\n| `hoverable` | `hoverable` | boolean | Whether this tooltip should be opened by hovering / tapping on the trigger element | Tooltip |\n| `stretch` | `stretch` | boolean | Whether this button stretch to fill up container's width | Button |\n| `allowNegativeValue` | `allowNegativeValue` | boolean | Allow negative value | CurrencyInput |\n| `childrenOverflowVisible` | `childrenOverflowVisible` | boolean | To apply `overflow-y: visible` for the `ChildrenWrapper` in some specific case that have to use some `custom Dropdown relatives` inside component | Drawer, Popup, LegacyPopup |\n| `isEmptyDrawer` | `isEmptyDrawer` | boolean | Empty Drawer without anything else | Drawer |\n| `multiple` | `multiple` | boolean | Allow multiple options | TagCloud |\n",
|
|
63
|
+
"title": "Overview/Props Index",
|
|
64
|
+
"description": "Because of history reasons, we did not standardize prop name at first which ended up multiple prop names",
|
|
65
|
+
"filePath": "website/about/2.5-props-index.stories.mdx"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"frontmatter": {},
|
|
69
|
+
"content": "import { Meta, Markdown } from '@storybook/addon-docs/blocks';\nimport Changelog from \"@chotot/clad-ui/CHANGELOG.md?raw\";\n\n<Meta\n title=\"Overview/Changelog\"\n parameters={{ previewTabs: { canvas: { hidden: true } } }}\n/>\n\n<Markdown>{Changelog}</Markdown>\n",
|
|
70
|
+
"title": "Overview/Changelog",
|
|
71
|
+
"filePath": "website/about/2.4-changelog.stories.mdx"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"frontmatter": {},
|
|
75
|
+
"content": "import { Meta } from '@storybook/addon-docs/blocks';\n\n<Meta\n title=\"Overview/Solution Rationale\"\n parameters={{ previewTabs: { canvas: { hidden: true } } }}\n/>\n\n# Solution Rationale\n\nClad UI uses a new hybrib approach of building React components: CSS-in-JS during component authoring, but final output is still static CSS.\n\n## Why Clad UI uses Linaria?\n\nFrom Linaria's Docs: [Benefits](https://github.com/callstack/linaria/blob/master/docs/BENEFITS.md).\n\n### Advantages over regular CSS\n\n#### 1. Selectors are scoped\n\nUnlike regular CSS, Linaria will generate scoped class names so that there's no collision between multiple styles in a large application. It's automatic, unlike conventions such as BEM.\n\nFor example, consider the following:\n\n```js\nconst title = css`\n font-size: 18px;\n`;\n```\n\nThe resulting CSS will look something like:\n\n```css\n.k4yi6fg {\n font-size: 18px;\n}\n```\n\nHere the generated class name is unique and based on the hash of the file path.\n\n#### 2. Styles are in same file as the component\n\nWith regular CSS, you'll need to create a separate file to write the CSS. This can be annoying when working with components because you'll need to do constant switching between the JS and CSS files while you're tweaking the styles. With Linaria, you can have the styles in the same file as rest of the JS.\n\nYou can also keep the styles in a separate JS file if you want, of course.\n\n#### 3. Refactor with confidence\n\nYou don't have to worry about breaking an unrelated component when changing and removing styles. Since Linaria's styles are like regular JavaScript variables, it's easy to track their usage and refactor.\n\n#### 4. No pre-processor needed\n\nLinaria supports JavaScript expressions, which enables you to generate style rules inside a declaration programmatically with JavaScript. You can share constants and helper functions between your CSS and JavaScript freely.\n\nFor example, here we are using a `lighten` helper from a third-party library:\n\n```js\nimport { lighten } from 'polished';\n\nconst PRIMARY_COLOR = '#de2d68';\n\nconst button = css`\n background-color: ${PRIMARY_COLOR};\n\n &:hover {\n background-color: ${lighten(0.2, PRIMARY_COLOR)};\n }\n`;\n```\n\n#### 5. Automatic unused styles removal\n\nLinaria automatically drops unused styles in a file unless it is exported. Linters like [ESLint](https://eslint.org/) can also warn you about when you have unused styles since they are just normal JS variables.\n\n#### 6. Automatic vendor prefixing\n\nLinaria will automatically vendor prefix your CSS, so you don't have to worry about supporting older browsers. You write modern CSS, and Linaria takes care of the rest.\n\nYou can still use tools like [PostCSS](https://postcss.org/) to further optimize the CSS.\n\n#### 7. Declarative dynamic styling with React\n\nWhen using the `styled` helper, Linaria will generate dynamic CSS variables which automatically update when props change. When writing regular CSS, you'll have to manage it manually.\n\nFor example, here the `height` and `width` will automatically update based on the `size` prop of `Box`:\n\n```js\nconst Box = styled.div`\n background-color: orange;\n height: ${props => props.size}px;\n width: ${props => props.size}px;\n`;\n\n<Box size={48}>\n```\n\n### Advantages over CSS preprocessors\n\n#### 1. No new syntax to learn\n\nLinaria's syntax is just like regular CSS, plus ability to nest selectors for convenience. There's no new syntax for variables, mixins or functions. It's just JavaScript.\n\n#### 2. Same advantages as regular CSS\n\nLinaria has all the same advantages mentioned in \"Advantages over regular CSS\" even when you are using a CSS pre-processor.\n\n## Advantages over inline styles\n\n#### 1. Full power of CSS\n\nUnlike inline styles, you have the full power of CSS with Linaria, such as:\n\n- Media queries\n- Animation keyframes\n- Hover, focus states etc.\n- Pseudo-selectors\n\n#### 2. Performance\n\nClass names perform much faster than inline styles.\n\n## Advantages over other CSS-in-JS solutions\n\n#### 1. CSS is downloaded and parsed separately from JS\n\nSince the styles are extracted to separate CSS files, the CSS and JavaScript can be downloaded and parsed by the browser in parallel and can improve the load time.\n\n#### 2. No extra parsing needed for CSS\n\nMany CSS-in-JS libraries parse the CSS string using a custom parser on the client. This increases the bundle size (albeit slightly) due to the inclusion of the parser. In addition, the CSS cannot be parsed until the JavaScript code is parsed and executed, which can be noticable, especially on low-end devices and bigger JS bundles.\n\nLinaria is unique in the sense that it doesn't need a runtime to work. Styles are parsed, evaluated and generated at build time and no extra parsing is needed on the client.\n\n#### 3. No style duplication on SSR\n\nFor component based CSS in JS libraries, rendering same component with different props can lead to duplicating the same set of styles multiple times. It doesn't matter on client side, but may increase the size of the rendered CSS when doing SSR. It may not matter in most cases, but in cases where you are rendering a large list of elements with tiny differences in styles, it can quickly add up.\n\nIn addition, when you do SSR, the rendered CSS is downloaded in addition to the CSS you wrote in JS files, further increasing the size.\n\nLinaria produces only one rule set per declaration, and the differences are taken care of using CSS variables, so there's no duplication, which is great for reducing bundle size.\n\n#### 4. Catch errors early due to build-time evaluation\n\nWhen you interpolate invalid values in Linaria (for example NaN in styles), you'll get a build time error. So you don't accidentally ship bugs into production and realize it later.\n\nLinaria's stylelint processor is also more robust and can lint styles much better, like you're writing vanilla CSS files.\n\n#### 5. Familiar CSS syntax\n\nUnlike some CSS in JS libraries, Linaria lets you write normal CSS syntax, which means you can copy paste styles from the browser's dev tools (or StackOverflow), and avoid unnecessary noise in the styles.\n\nYou can also use a pre-processor such as Sass if you prefer.\n\n#### 6. Works without JavaScript\n\nIf your website needs to work without JavaScript, or you generate the HTML in advance at build time, Linaria is a great fit for styling such websites.\n",
|
|
76
|
+
"title": "Overview/Solution Rationale",
|
|
77
|
+
"description": "Clad UI uses a new hybrib approach of building React components: CSS-in-JS during component authoring, but final output is still static CSS.",
|
|
78
|
+
"filePath": "website/about/2.3-solution-rationale.stories.mdx"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"frontmatter": {},
|
|
82
|
+
"content": "import { Meta } from '@storybook/addon-docs/blocks';\n\n<Meta\n title=\"Overview/Contributor Guide\"\n parameters={{ previewTabs: { canvas: { hidden: true } } }}\n/>\n\n# Clad UI Development Guide\n\n## Building new components quick start\n\n[Detailed writeup pending]\n\n- Use `cx` instead of `classnames`\n- Use `polished` for computed styles (`polished` will be tree-shaken after CSS generation)\n- Write up sample component structure\n + [Prefered] When to use static class-based styles (`css` util)\n + When to use dynamic prop-based styles (`styled` util)\n- Write up component story file guide\n\n## Verifying @chotot/clad-ui components in production\n\nOpen browser Devtool (F12) and add following CSS to the `:root` element:\n\n```css\n:root {\n /* Highlight @chotot/clad-ui components: setting the color of element `outline` */\n --cladebug: magenta;\n /* [Optional] Display component label: setting the label's pseudo-element `display` property */\n --cladebug-label: block;\n}\n```\n",
|
|
83
|
+
"title": "Overview/Contributor Guide",
|
|
84
|
+
"description": "## Building new components quick start",
|
|
85
|
+
"filePath": "website/about/2.2-contribution-guide.stories.mdx"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"frontmatter": {},
|
|
89
|
+
"content": "import { Meta } from '@storybook/addon-docs/blocks';\n\n<Meta\n title=\"Overview/In-depth Guide\"\n parameters={{ previewTabs: { canvas: { hidden: true } } }}\n/>\n\n# In-depth Styling with Clad UI and Linaria\n\n> From: https://github.com/callstack/linaria/blob/master/docs/BASICS.md\n\n### The `css` tag\n\nThe `css` tag allows you to create simple class names:\n\n```js\nimport { css } from '@linaria/core';\n\n// Create a class name\nconst title = css`\n font-size: 24px;\n font-weight: bold;\n`;\n\nfunction Heading() {\n // Pass it to a component\n return <h1 className={title}>This is a title</h1>;\n}\n```\n\nHere the value of the `title` variable will be a unique class name which you can pass in the `className` prop. This code is equivalent to the following CSS and JavaScript.\n\nCSS:\n\n```css\n.title {\n font-size: 24px;\n font-weight: bold;\n}\n```\n\nJavaScript:\n\n```js\nfunction Heading() {\n return <h1 className=\"title\">This is a title</h1>;\n}\n```\n\n### The `styled` tag\n\nThe `styled` tag allows you to create a React component with some styles already applied.\n\nYou write `styled` followed by the name of the HTML tag you want to use, e.g. `styled.div`, `styled.a`, `styled.button`, `styled.h3` etc.\n\n```js\nimport { styled } from '@linaria/react';\n\n// Create a styled component\nconst Title = styled.h1`\n font-size: 24px;\n font-weight: bold;\n`;\n\nfunction Heading() {\n // Use the styled component\n return <Title>This is a title</Title>;\n}\n```\n\nThis reduces quite a bit of boilerplate code you had to write when you manually created the class name and applied it to a tag. This code is equivalent to the following CSS and JavaScript.\n\nCSS:\n\n```css\n.title {\n font-size: 24px;\n font-weight: bold;\n}\n```\n\nJavaScript:\n\n```js\nfunction Title(props) {\n return <h1 {...props} className=\"title\" />;\n}\n\nfunction Heading() {\n return <Title>This is a title</Title>;\n}\n```\n\nApart from the reduced boilerplate code, this also makes it easier to do prop based styling which you'll cover later in the guide.\n\n### Nesting, pseudo-elements and pseudo-selectors\n\nYou can nest selectors, pseudo-elements and pseudo-selectors similar to Sass, thanks to [stylis](https://github.com/thysultan/stylis.js).\n\nFor example, to change the color of a button on hover, you'll write something like this:\n\n```js\nconst Button = styled.button`\n color: black;\n\n &:hover {\n color: blue;\n }\n`;\n```\n\nThe value of `&` refers to the class name. This code is equivalent to the following CSS:\n\n```css\n.button {\n color: black;\n}\n\n.button:hover {\n color: blue;\n}\n```\n\nYou can nest pseudo-elements as well as other selectors:\n\n```js\nconst Thing = styled.div`\n color: black;\n\n &::after {\n /* .thing::after */\n content: '🌟';\n }\n\n h3 {\n /* .thing h3 */\n color: tomato;\n }\n\n .code {\n /* .thing .code */\n color: #555;\n }\n\n & + & {\n /* .thing + .thing */\n background: yellow;\n }\n\n &.bordered {\n /* .thing.bordered */\n border: 1px solid black;\n }\n\n .parent & {\n /* .parent .thing */\n color: blue;\n }\n`;\n```\n\nYou can also nest media queries:\n\n```js\nconst Thing = styled.div`\n color: black;\n\n @media (min-width: 200px) {\n color: blue;\n }\n`;\n```\n\nThis is equivalent to the following CSS:\n\n```css\n.thing {\n color: black;\n}\n\n@media (min-width: 200px) {\n .thing {\n color: blue;\n }\n}\n```\n\n### Keyframe animations\n\nYou can write keyframe declarations right inside the template literal:\n\n```js\nconst Box = styled.div`\n height: 200px;\n width: 200px;\n background-color: tomato;\n animation: spin 2s linear infinite;\n\n @keyframes spin {\n from {\n transform: rotate(0deg);\n }\n\n to {\n transform: rotate(360deg);\n }\n }\n`;\n```\n\nHere `spin` will be replaced with a unique string to scope the animation to the class name.\n\n## Interpolations\n\nLike normal template literals, you can interpolate other expressions inside a template literal tagged with `css` or `styled`.\n\nIf you try to interpolate an invalid value, you'll get an error at build-time.\n\n### Basic interpolations\n\nYou can interpolate variables declared in the same file as well as imported variables:\n\n```js\nconst fontSize = 16;\n\nconst Title = styled.h1`\n font-size: ${fontSize}px;\n`;\n```\n\nHere, the `fontSize` variable will be evaluated at build time and inserted into the generated CSS.\n\nYou can also call functions while interpolating:\n\n```js\nconst Button = styled.button`\n background-color: ${colors.backgroundBrand};\n\n &:hover {\n background-color: ${darken(0.2, colors.backgroundBrand)};\n }\n`;\n```\n\n### Object interpolations\n\nYou can also interpolate object styles. It's converted to a CSS string before inserting to the stylesheet:\n\n```js\nconst cover = {\n position: 'absolute',\n top: 0,\n right: 0,\n bottom: 0,\n left: 0,\n opacity: 1,\n minHeight: 360,\n\n '@media (min-width: 200px)': {\n minHeight: 480,\n },\n};\n\nconst Title = styled.h1`\n font-size: 24px;\n\n ${cover};\n`;\n```\n\nThis is equivalent to the following CSS:\n\n```js\nconst Title = styled.h1`\n font-size: 24px;\n\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n opacity: 1;\n min-height: 360px;\n\n '@media (min-width: 200px)': {\n minheight: 480px;\n }\n`;\n```\n\nThe interpolated object can have nested selectors, media queries, pseudo-selectors and pseudo-elements. Numeric values which require a unit (e.g. `minHeight` in the above example) will be appended with `px` unless specified.\n\n### Prop based styles\n\nWhen writing React components using the `styled` syntax, you can write styles based on the component's props. These values will use [CSS variables](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables) under the hood and can change dynamically in runtime.\n\nFor dynamic prop based styles, pass a function to the interpolation:\n\n```js\nconst Title = styled.h1`\n color: ${props => (props.primary ? 'tomato' : 'black')};\n`;\n```\n\nThe function will be called with the component's props as an argument when it is rendered. Here, the color of the title will be automatically updated whenever the value of the `primary` prop changes.\n\n### Referring to another component or class name\n\nYou can interpolate a styled component or a class name to refer to it. For example:\n\n```js\nconst title = css`\n font-size: 24px;\n color: black;\n`;\n\nconst Paragraph = styled.p`\n font-size: 16px;\n color: #555;\n`;\n\nconst Article = styled.article`\n /* when referring to class names, prepend a dot (.) */\n .${title} {\n font-size: 36px;\n }\n\n /* when referring to a component, interpolate it as a selector */\n ${Paragraph} {\n font-size: 14px;\n margin: 16px;\n }\n`;\n```\n\n## Overriding styles\n\nIf you want to override few styles on a styled component you defined earlier, you can do so by wrapping it in the `styled(..)` tag:\n\n```js\nconst Button = styled.button`\n font-size: 14px;\n background-color: tomato;\n padding: 8px;\n box-shadow: 0 0.5px 0.3px rgba(0, 0, 0, 0.1);\n`;\n\nconst LargeButton = styled(Button)`\n font-size: 18px;\n padding: 16px;\n`;\n```\n\nHere, when you use `LargeButton`, it'll have all the same styles as `Button` except the `font-size` and `padding` which we overrode.\n\n## Styling custom components\n\nYou can use the `styled(..)` tag to style any component as long as they accept a `className` and a `style` prop:\n\n```js\nfunction CoolComponent({ className, style, ...rest }) {\n return (\n <div className={className} style={style}>\n {...}\n </div>\n );\n}\n\nconst StyledCoolComponent = styled(CoolComponent)`\n background-color: tomato;\n`;\n```\n\nThe `style` prop is necessary to apply CSS variables. If you're using a component library that doesn't support passing a `style` prop, you can wrap it in a `div` (or any other tag that makes sense) to apply it:\n\n```js\nimport { Card } from 'some-library';\n\nfunction CustomCard({ className, style, ...rest }) {\n return (\n <div style={style}>\n <Card className={className} {...rest} />\n </div>\n );\n}\n\nconst StyledCustomCard = styled(CustomCard)`\n margin: 16px;\n height: ${props => props.height}px;\n`;\n```\n\nIf you want to use linaria classname, which is generated for component, you can get it as last item from `className` prop:\n\n```js\nfunction CoolComponent({ className, style, variant, ...rest }) {\n const allClasses = className.split(' ');\n const linariaClassName = allClasses[allClasses.length - 1];\n\n const classes = cx(\n className,\n variant === 'primary' && `${linariaClassName}--primary`\n );\n\n return (\n <div className={classes} style={style}>\n {...}\n </div>\n );\n}\n\nconst StyledCoolComponent = styled(CoolComponent)`\n background-color: tomato;\n\n &--primary {\n background-color: yellow;\n }\n`;\n```\n\n## Adding global styles\n\nNormally, the styles are scoped to specific components. But sometimes you may need to write some global styles, for example, to normalize browser inconsistencies, define a font-family etc.\n\nYou can do the following to generate unscoped global styles:\n\n```js\nexport const globals = css`\n :global() {\n html {\n box-sizing: border-box;\n }\n\n *,\n *:before,\n *:after {\n box-sizing: inherit;\n }\n\n @font-face {\n font-family: 'MaterialIcons';\n src: url(../assets/fonts/MaterialIcons.ttf) format('truetype');\n }\n }\n`;\n```\n\nIt's not possible to use dynamic prop based styles inside global styles.\n",
|
|
90
|
+
"title": "Overview/In-depth Guide",
|
|
91
|
+
"description": "> From: https://github.com/callstack/linaria/blob/master/docs/BASICS.md",
|
|
92
|
+
"filePath": "website/about/2.1-development-guide.stories.mdx"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"frontmatter": {},
|
|
96
|
+
"content": "import { Meta, Markdown } from '@storybook/addon-docs/blocks';\nimport ReadmeContent from '@chotot/clad-ui-tailwind/README.md?raw';\n\n<Meta\n title=\"Overview/Getting Started (Tailwind)\"\n parameters={{ previewTabs: { canvas: { hidden: true } } }}\n/>\n\n<Markdown>{ReadmeContent}</Markdown>",
|
|
97
|
+
"title": "Overview/Getting Started (Tailwind)",
|
|
98
|
+
"filePath": "website/about/1.3-getting-started-tailwind.stories.mdx"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"frontmatter": {},
|
|
102
|
+
"content": "import { Meta } from '@storybook/addon-docs/blocks';\n\n<Meta title=\"Overview/Getting Started\" parameters={{ previewTabs: { canvas: { hidden: true } } }} />\n\n# Getting Started\n\n## Install\n\n```bash\npnpm add @chotot/clad-ui@latest react@^18 react-dom@^18 react-laag@^2.0.5\n```\n\nClad UI ships prebuilt JavaScript bundles and theme CSS files. Consuming apps do not need\nLinaria, Babel presets, or bundler-specific style loaders.\n\n## Load a Theme\n\nImport exactly one theme stylesheet once in your app entrypoint:\n\n```ts\nimport '@chotot/clad-ui/theme/chotot.css';\n// or\nimport '@chotot/clad-ui/theme/job.css';\nimport '@chotot/clad-ui/theme/pty.css';\nimport '@chotot/clad-ui/theme/veh.css';\n```\n\nThe theme stylesheet includes Clad UI's baseline styles, so you do not need a separate\n`@chotot/clad-ui/css/baseline` import.\n\n## Use\n\nHow to import @chotot/clad-ui components and its utilities:\n\n```tsx\nimport '@chotot/clad-ui/theme/chotot.css';\n\nimport {\n Button,\n Location,\n SearchInput,\n cx,\n sx,\n theme,\n} from '@chotot/clad-ui';\n```\n\nImport components, patterns, icons, utilities, and theme tokens from the package root.\nLegacy subpath imports such as `@chotot/clad-ui/components`, `@chotot/clad-ui/patterns`,\nand `@chotot/clad-ui/css/baseline` are not part of the current package exports.\n\n## Getting Started with @chotot/clad-ui Development\n\n#### `pnpm install`\n\nInstall dependencies and bootstrap development environment\n\n#### `pnpm --filter @chotot/clad-ui dev`\n\nRun the package build in watch mode with Vite\n\n#### `pnpm --filter website dev`\n\nStart the Storybook documentation site locally\n\n#### `pnpm --filter @chotot/clad-ui build`\n\nBuild library bundles, type definitions, and theme CSS assets\n\n#### `pnpm --filter website build`\n\nBuild Storybook to a static website in `website/public`\n\n#### `pnpm --filter website start`\n\nPreview the built Storybook site\n\n## Migrate from Older Linaria-based Setup\n\nIf your app was configured for the previous Linaria-based setup, remove that configuration\nand switch to the published CSS assets instead:\n\n```diff\n- pnpm add @chotot/clad-ui @linaria/core @linaria/react\n- pnpm add --save-dev @linaria/babel-preset @linaria/webpack-loader\n+ pnpm add @chotot/clad-ui react react-dom react-laag\n\n- import '@chotot/clad-ui/css/baseline';\n- import theme from '@chotot/clad-ui/theme';\n- import { css } from '@linaria/core';\n- import { styled } from '@linaria/react';\n+ import '@chotot/clad-ui/theme/chotot.css';\n+ import { Button, theme } from '@chotot/clad-ui';\n```\n\nClad UI no longer exposes Linaria styling helpers to consuming apps. Keep using your app's\nown styling solution for application-specific styles.\n\n## Resources\n\n- [Vite Documentation](https://vite.dev/guide/)\n- [System UI Theme Specs](https://theme-ui.com/theme-spec/)\n",
|
|
103
|
+
"title": "Overview/Getting Started",
|
|
104
|
+
"description": "## Install",
|
|
105
|
+
"filePath": "website/about/1.2-getting-started.stories.mdx"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"frontmatter": {},
|
|
109
|
+
"content": "import { Meta, Markdown } from \"@storybook/addon-docs/blocks\";\nimport Readme from \"@chotot/clad-ui/README.md?raw\";\n\n<Meta\n title=\"Overview/Intro\"\n parameters={{ previewTabs: { canvas: { hidden: true } } }}\n/>\n\n<div className=\"intro-banner\">\n <div>\n # Clad UI <br /> Design System\n\n A system of design tokens, style guide, theming solution and components\n library from the team at Chợ Tốt.\n </div>\n <img src=\"./hero.png\" />\n</div>\n\n<Markdown>{Readme}</Markdown>\n",
|
|
110
|
+
"title": "Overview/Intro",
|
|
111
|
+
"filePath": "website/about/1.1-intro.stories.mdx"
|
|
112
|
+
}
|
|
113
|
+
],
|
|
114
|
+
"patterns": [
|
|
115
|
+
{
|
|
116
|
+
"frontmatter": {},
|
|
117
|
+
"content": "import { Meta } from '@storybook/addon-docs/blocks';\n\n<Meta title=\"Patterns/Intro\" parameters={{ previewTabs: { canvas: { hidden: true } } }} />\n\n# Patterns\n\nPatterns are composite components which are comprized of small and primitive components. Patterns should also be portable.\n\n## Pattern Guidelines\n\n- Patterns should be **composed of other's clad UI components**. Else, it looks like a primitive Components.\n- Patterns should be **portable** and with as **few external dependencies** as possible.\n- Patterns should be **resuable** in multiple occurrences. If it is one-and-only, consider keeping it at the application level.\n- Patterns should be **stateless** (a.k.a **presentational**, ie. no data binding nor global state connection within)\n- Patterns are not Views or Pages.\n\n",
|
|
118
|
+
"title": "Patterns/Intro",
|
|
119
|
+
"description": "Patterns are composite components which are comprized of small and primitive components. Patterns should also be portable.",
|
|
120
|
+
"filePath": "website/patterns/4.1-patterns.stories.mdx"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"frontmatter": {},
|
|
124
|
+
"content": "import { Meta } from '@storybook/addon-docs/blocks';\n\n<!-- Redirection entry at Components/Inputs page -->\n<Meta title=\"Components/Inputs/Search Input\" parameters={{ previewTabs: { canvas: { hidden: true } } }} />\n\n# Search Input\n\n[Visit Patterns > Search Input](?path=/docs/patterns-search-input--overview)\n\n\n\n",
|
|
125
|
+
"title": "Components/Inputs/Search Input",
|
|
126
|
+
"description": "[Visit Patterns > Search Input](?path=/docs/patterns-search-input--overview)",
|
|
127
|
+
"filePath": "packages/clad-ui/patterns/SearchInput/SearchInput.stories.mdx"
|
|
128
|
+
}
|
|
129
|
+
],
|
|
130
|
+
"components": []
|
|
131
|
+
}
|