Skip to content

Commit 2e5485c

Browse files
committed
docs(style): theming and foundation styles
1 parent a585d3b commit 2e5485c

File tree

7 files changed

+133
-19
lines changed

7 files changed

+133
-19
lines changed

.github/workflows/sync-to-gist.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Sync to Gist
1+
name: Sync to Lu Khei's Gist
22
on:
33
push:
44
branches:
@@ -15,4 +15,15 @@ jobs:
1515
with:
1616
gist_token: ${{ secrets.GIST_TOKEN }}
1717
gist_id: 425e29332ec837d9ea4bbe90ff8d4a37
18-
source_path: src/themes
18+
source_path: src/themes
19+
CSS-Gist:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
- name: Gist Repo Sync
25+
uses: pentatonicfunk/action-gist-repo-sync@v1.8
26+
with:
27+
gist_token: ${{ secrets.GIST_TOKEN }}
28+
gist_id: a31bfc0ea0c2b87d950b125f92835a76
29+
source_path: src/css

.storybook/preview.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export const parameters = {
5353
["Introduction", "Installation", "Imports"],
5454
"Usage",
5555
"Frameworks",
56+
"Style",
5657
"Troubleshooting",
5758
"Components",
5859
"Patterns",

docs/FoundationalStyles.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Foundation
2+
3+
The library also provides styles for SGDS foundation to help users style your application wholistically with SGDS.
4+
The styles help to override the default browser's native styles with SGDS.
5+
6+
These files are distributed as CSS files and are optional to import. These styles do not affect the web components and are not required in the web component.
7+
However, do note that the CSS styles the light dom and may causes clash of styles if there are other styling libraries (for example, tailwind, bootstrap, sgds v1 and v2 css, etc.) used in your app.
8+
9+
Foundation aspects of SGDS includes:
10+
- typography,
11+
- body `<body>`
12+
- paragraphs `<p>`
13+
- labels `<label>`
14+
- anchor `<a>`
15+
- captions `<caption>`
16+
- headers `<h1>, <h2>, <h3>, <h4>, <h5>, <h6>`
17+
- list `<ol>, <ul>, <li>`
18+
- grid system <sgds-badge show>work in progress</sgds-badge>
19+
20+
## Import
21+
22+
The CSS styles are dependent on the css variable tokens. Import the `themes/day.css` file first before importing the css files. If you required night mode, import `themes/night.css` as well.
23+
The colors assigned to elements and class selectors will switch depending on day or night mode.
24+
25+
<strong>JS imports</strong>
26+
27+
```js
28+
import "@govtechsg/sgds-web-component/themes/day.css"
29+
//optional: if you are doing night mode
30+
import "@govtechsg/sgds-web-component/themes/night.css"
31+
import "@govtechsg/sgds-web-component/css/sgds.css"
32+
33+
```
34+
35+
<strong>CSS imports</strong>
36+
37+
```css
38+
@import "@govtechsg/sgds-web-component/themes/day.css";
39+
/** optional: if you are doing night mode */
40+
@import "@govtechsg/sgds-web-component/themes/night.css";
41+
@import "@govtechsg/sgds-web-component/css/sgds.css";
42+
```
43+
44+
### Cherry pick the styles
45+
46+
`css/sgds.css` contains all the stylings found in the folder `css`. You can also choose to cherry pick the styles you required. For example, `label.css`
47+
48+
<strong>JS imports</strong>
49+
50+
```js
51+
import "@govtechsg/sgds-web-component/themes/day.css"
52+
//optional: if you are doing night mode
53+
import "@govtechsg/sgds-web-component/themes/night.css"
54+
import "@govtechsg/sgds-web-component/css/label.css"
55+
56+
```
57+
58+
<strong>CSS imports</strong>
59+
60+
```css
61+
@import "@govtechsg/sgds-web-component/themes/day.css";
62+
/** optional: if you are doing night mode */
63+
@import "@govtechsg/sgds-web-component/themes/night.css";
64+
@import "@govtechsg/sgds-web-component/css/label.css";
65+
```
66+
67+
## Source files
68+
69+
<iframe
70+
src='https://gist.github.com/clukhei/a31bfc0ea0c2b87d950b125f92835a76.pibb'
71+
style="width: 100%; height: 1000px; border: 0;"
72+
>
73+
</iframe>

docs/Stylings.md renamed to docs/Theming.md

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
# Stylings
1+
# Stylings
22

33
## Global Styles and Theming
44

55
Customize the styles at the `:root` level by overriding the values of css tokens defined in file
66
`@govtechsg/sgds-web-component/themes/day.css` file. This file contains the primitive and semantic css tokens. For system level UI changes, we encourage you to make primitive and semantic level style changes at the `:root` rather than component specific changes.
77

8-
See all tokens in [github](https://github.com/GovTechSG/sgds-web-component/blob/restructure-v2/src/themes/day.css)
9-
108
```css
119
// yourCustomCss.css
1210
:root {
@@ -21,13 +19,41 @@ import "@govtechsg/sgds-web-component/themes/day.css";
2119
import "./yourCustomCss.css"
2220
```
2321

24-
## Component specific styles
22+
### root.css
23+
24+
Primitives and semantic values are defined here. These tokens can also be found in `@govtechsg/sgds-web-component/themes` folder.
25+
26+
<iframe
27+
src='https://gist.github.com/clukhei/425e29332ec837d9ea4bbe90ff8d4a37.pibb?file=root.css'
28+
style="width: 100%; height: 300px; border: 0;"
29+
>
30+
</iframe>
31+
32+
### day.css
33+
34+
<iframe
35+
src='https://gist.github.com/clukhei/425e29332ec837d9ea4bbe90ff8d4a37.pibb?file=day.css'
36+
style="width: 100%; height: 300px; border: 0;"
37+
>
38+
</iframe>
39+
40+
### night.css
2541

26-
The styles of components are built in and can be modified via cssparts or css custom properties whenever we specify for such styling modificiations. This information will be specified under API section for each component
42+
<iframe
43+
src='https://gist.github.com/clukhei/425e29332ec837d9ea4bbe90ff8d4a37.pibb?file=night.css'
44+
style="width: 100%; height: 300px; border: 0;"
45+
>
46+
</iframe>
47+
48+
49+
50+
## Component specific styles <sgds-badge show>work in progress</sgds-badge>
51+
52+
<!-- The styles of components are built in and can be modified via cssparts or css custom properties whenever we specify for such styling modificiations. This information will be specified under API section for each component
2753
2854
You will require some knowledge of web components and css to do so and the information can be readily available online like mdn web docs for [web components](https://developer.mozilla.org/en-US/docs/Web/Web_Components) and [css](https://developer.mozilla.org/en-US/docs/Web/CSS)
2955
30-
### css custom variable
56+
### css custom variable <sgds-badge show>work in progress</sgds-badge>
3157
3258
Some components have defined css custom variable for styling of selected aspects of the element in the shadow DOM. See the API table for the available css custom variables
3359
@@ -37,7 +63,7 @@ sgds-sidenav {
3763
}
3864
```
3965
40-
### cssparts
66+
### cssparts <sgds-badge show>work in progress</sgds-badge>
4167
4268
Some components expose cssparts on selected elements of the shadow DOM. See the API table for each component on the css parts exposed.
4369
@@ -47,9 +73,6 @@ sgds-footer::part(footer-bottom) {
4773
font-family: "Times New Roman", Times, serif;
4874
border: 10px dotted red;
4975
}
50-
```
51-
76+
``` -->
5277

53-
## External stylings
5478

55-
Any external stylings done on our web components like positioning needs to be done on your end. You can use [SGDS v2 library](https://designsystem.tech.gov.sg/get-started/)to leverage on the position stylings we provide e.g. ms-auto, flexbox, grids
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { Meta, Markdown } from "@storybook/blocks";
2+
import FoundationalStyles from '../../../docs/FoundationalStyles.md?raw';
3+
4+
<Meta title="Style/Foundation" />
5+
6+
<Markdown>{FoundationalStyles}</Markdown>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { Meta, Markdown } from "@storybook/blocks";
2+
import Theming from '../../../docs/Theming.md?raw';
3+
4+
<Meta title="Style/Theming" />
5+
6+
<Markdown>{Theming}</Markdown>

stories/getting-started/Usage/Stylings.mdx

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)