Skip to content

Commit 6358a94

Browse files
authored
Merge pull request #213 from Tap30/feat/add-design-guidline-template
docs: add design layout
2 parents f34191b + 242ca02 commit 6358a94

40 files changed

+732
-203
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,4 @@ storybook-static
6464
# Vitepress
6565
docs/.vitepress/dist
6666
docs/.vitepress/cache
67-
docs/components/custom-elements.json
67+
docs/dev/components/custom-elements.json

docs/.vitepress/nav.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@ import { DefaultTheme } from "vitepress";
33
export default [
44
{
55
text: 'Getting Started',
6-
link: '/getting-started',
6+
link: '/dev/getting-started',
77
},
88
{
99
text: 'Components',
10-
link: '/components/tap-avatar',
10+
link: '/dev/components/tap-avatar',
11+
},
12+
{
13+
text: 'Design Guidelines',
14+
link: '/design/guidelines',
1115
},
1216
{
1317
text: 'Related Links',

docs/.vitepress/sidebar.ts

+71-38
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,83 @@ import fs from 'fs';
22
import { DefaultTheme } from "vitepress";
33
import type { Package } from "custom-elements-manifest";
44

5-
const file = fs.readFileSync('dist/custom-elements.json');
6-
const manifest = JSON.parse(file.toString()) as Package;
5+
const getComponentsDevItems = () => {
6+
const file = fs.readFileSync('dist/custom-elements.json');
7+
const manifest = JSON.parse(file.toString()) as Package;
8+
return manifest.modules
9+
.filter((module) => !!module.declarations?.length)
10+
.map((module) => {
11+
if (!module.exports)
12+
throw new Error(`Module has no export: ${module.path}`);
713

8-
const components = manifest.modules
9-
.filter((module) => !!module.declarations?.length)
10-
.map((module) => {
11-
if (!module.exports)
12-
throw new Error(`Module has no export: ${module.path}`);
14+
const components = module.exports.filter(
15+
(exp) => exp.kind === 'custom-element-definition',
16+
);
1317

14-
const components = module.exports.filter(
15-
(exp) => exp.kind === 'custom-element-definition',
16-
);
17-
18-
// For now we asume we have only one custom element per moduel
19-
const component = components[0];
18+
// For now, we assume we have only one custom element per module
19+
const component = components[0];
2020

2121
return {
2222
link: '/components/' + component.name,
2323
text: component.name,
2424
};
2525
});
26+
}
27+
28+
const getSidebarDevContents = (): DefaultTheme.Sidebar => {
29+
return [
30+
{text: 'Getting Started', link: '/getting-started'},
31+
{
32+
text: 'Design System Guidelines',
33+
base: '/design/',
34+
link: '/guidelines'
35+
},
36+
{
37+
text: 'Components',
38+
collapsed: false,
39+
items: getComponentsDevItems(),
40+
},
41+
{
42+
text: 'API References',
43+
collapsed: false,
44+
items: [
45+
{text: 'CSS Parts', link: '/references/css-parts'},
46+
{
47+
text: 'Design Tokens', items: [
48+
{text: 'Colors', link: '/references/color-tokens'},
49+
{text: 'Radius', link: '/references/radius-tokens'},
50+
{text: 'Spacing', link: '/references/spacing-tokens'},
51+
{text: 'Stroke', link: '/references/stroke-tokens'},
52+
{text: 'Typography', link: '/references/typography-tokens'},
53+
{text: 'Components', link: '/references/components-tokens'},
54+
]
55+
},
56+
],
57+
},
58+
];
59+
}
60+
61+
const getComponentsDesignItems = () => {
62+
const componentGuidelinesBasePath = 'docs/design/components'
63+
const files = fs.readdirSync(componentGuidelinesBasePath)
64+
.filter((file) => file.endsWith('.md'))
65+
.map((file) => file.replace('.md', ''));
66+
return files.map((file) => {
67+
return {
68+
link: 'components/' + file,
69+
text: file,
70+
};
71+
});
72+
};
73+
74+
const getSidebarDesignContents = (): DefaultTheme.Sidebar => {
75+
return [
76+
{text: 'Introduction', link: '/guidelines'},
77+
{text: 'Component Guidelines', base: '/design/', items: getComponentsDesignItems()}
78+
];
79+
}
2680

27-
export default [
28-
{ text: 'Getting Started', link: '/getting-started' },
29-
{
30-
text: 'Components',
31-
collapsed: false,
32-
items: components,
33-
},
34-
{
35-
text: 'API References',
36-
collapsed: false,
37-
items: [
38-
{ text: 'CSS Parts', link: '/references/css-parts' },
39-
{
40-
text: 'Design Tokens', items: [
41-
{ text: 'Colors', link: '/references/color-tokens' },
42-
{ text: 'Radius', link: '/references/radius-tokens' },
43-
{ text: 'Spacing', link: '/references/spacing-tokens' },
44-
{ text: 'Stroke', link: '/references/stroke-tokens' },
45-
{ text: 'Typography', link: '/references/typography-tokens' },
46-
{ text: 'Components', link: '/references/components-tokens' },
47-
]
48-
},
49-
],
50-
},
51-
] as DefaultTheme.SidebarItem[]
81+
export default {
82+
'/dev/': { base: '/dev/', items: getSidebarDevContents() },
83+
'/design/': { base: '/design/', items: getSidebarDesignContents() },
84+
} as DefaultTheme.Sidebar

docs/.vitepress/theme/index.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
// .vitepress/theme/index.js
21
import DefaultTheme from 'vitepress/theme'
32
import './custom.css'
3+
import '../../components'
4+
import '../../../styles/theme.css'
45

5-
export default DefaultTheme
6+
export default {
7+
extends: DefaultTheme,
8+
}
6.68 KB
Loading

docs/assets/bottom-sheet-anatomy.png

12.4 KB
Loading
41.7 KB
Loading

docs/assets/bottom-sheet-contents.png

10.3 KB
Loading

docs/assets/bottom-sheet-do-1.png

39.2 KB
Loading

docs/assets/bottom-sheet-do-2.png

19.9 KB
Loading

docs/assets/bottom-sheet-dont-1.png

18.1 KB
Loading

docs/assets/bottom-sheet-dont-2.png

22.3 KB
Loading

docs/assets/bottom-sheet-specs-1.png

10.1 KB
Loading

docs/assets/bottom-sheet-specs-2.png

11.2 KB
Loading

docs/assets/bottom-sheet-title.png

10.7 KB
Loading

docs/assets/bottom-sheet-types.png

24.2 KB
Loading

docs/components/[component].md

-53
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import {css} from "lit";
2+
3+
export default css`
4+
:host {
5+
box-sizing: border-box;
6+
flex: 1;
7+
align-self: stretch;
8+
display: flex;
9+
}
10+
11+
:host *,
12+
:host *::before,
13+
:host *::after {
14+
box-sizing: inherit;
15+
}
16+
17+
.guideline-card {
18+
height: 100%;
19+
display: flex;
20+
flex-direction: column;
21+
align-items: flex-start;
22+
gap: 1rem;
23+
border-radius: 8px;
24+
padding: 16px 16px 8px;
25+
line-height: 24px;
26+
font-size: var(--vp-custom-block-font-size);
27+
border-color: var(--vp-custom-block-info-border);
28+
color: var(--vp-custom-block-info-text);
29+
background-color: var(--vp-custom-block-info-bg);
30+
}
31+
32+
.image {
33+
margin: auto;
34+
}
35+
.image img {
36+
width: 100%;
37+
}
38+
39+
.badge {
40+
display: inline-block;
41+
margin-left: 2px;
42+
border: 1px solid transparent;
43+
height: 26px;
44+
border-radius: 12px;
45+
padding: 0 10px;
46+
font-size: 12px;
47+
font-weight: 500;
48+
transform: translateY(10px);
49+
}
50+
51+
.do {
52+
background-color: var(--tap-palette-green-400);
53+
color: #ffffff;
54+
}
55+
.dont {
56+
background-color: var(--tap-palette-red-400);
57+
color: #ffffff;
58+
}
59+
.caution {
60+
background-color: var(--tap-palette-yellow-400);
61+
color: #000000;
62+
}
63+
64+
@media (max-width: 1100px) {
65+
:host {
66+
width: 100%;
67+
align-items: stretch;
68+
}
69+
.guideline-card {
70+
width: 100%;
71+
}
72+
}
73+
`;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import {html, LitElement, nothing} from 'lit';
2+
import {property} from 'lit/decorators.js';
3+
4+
export class GuidelineCard extends LitElement {
5+
@property({ attribute: 'image-url' }) imageUrl = '';
6+
7+
@property() variant?: 'do' | 'dont' | 'caution';
8+
9+
private renderBadge () {
10+
11+
const badgeConfig = {
12+
do: {
13+
title: 'Do',
14+
class: 'do'
15+
},
16+
dont: {
17+
title: 'Don\'t',
18+
class: 'dont'
19+
},
20+
caution: {
21+
title: 'Caution',
22+
class: 'caution'
23+
},
24+
}
25+
26+
27+
if (this.variant && Object.keys(badgeConfig).includes(this.variant)) {
28+
const selectedBadge = badgeConfig[this.variant];
29+
return html`<div class="badge ${selectedBadge.class}">${selectedBadge.title}</div>`
30+
}
31+
return nothing
32+
}
33+
34+
render() {
35+
return html`
36+
<div part="guideline-card" class="guideline-card ">
37+
<div class="image">
38+
<slot name="card-image"></slot>
39+
</div>
40+
${this.renderBadge()}
41+
<div class="content">
42+
<slot></slot>
43+
</div>
44+
</div>
45+
`;
46+
}
47+
}
48+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { customElement } from 'lit/decorators.js';
2+
import styles from './doc-guideline-card.style';
3+
import {GuidelineCard} from "./doc-guideline-card";
4+
5+
@customElement('doc-guideline-card')
6+
export class DocGuidelineCard extends GuidelineCard {
7+
static readonly styles = [styles];
8+
}
9+
10+
declare global {
11+
interface HTMLElementTagNameMap {
12+
'doc-guideline-card': DocGuidelineCard;
13+
}
14+
}

0 commit comments

Comments
 (0)