Skip to content

Commit

Permalink
Introduce Tag & Update Page
Browse files Browse the repository at this point in the history
  • Loading branch information
lucemans committed Feb 15, 2024
1 parent da61089 commit 5be4616
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 25 deletions.
7 changes: 0 additions & 7 deletions packages/thorin-core/src/button/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,6 @@ export class ThorinButton extends LitElement {
--color-hover: var(--thorin-text-accent);
--outline: var(--thorin-indigo-bright);
}
button.indigo {
--bg: var(--thorin-indigo-primary);
--bg-hover: var(--thorin-indigo-bright);
--color: var(--thorin-text-accent);
--color-hover: var(--thorin-text-accent);
--outline: var(--thorin-indigo-bright);
}
button.purple {
--bg: var(--thorin-purple-primary);
--bg-hover: var(--thorin-purple-bright);
Expand Down
1 change: 1 addition & 0 deletions packages/thorin-core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export { ThorinAvatar } from './avatar';
export { ThorinButton } from './button';
export { ThorinModal } from './modal';
export { ThorinTag } from './tag';

export const hello = () => {
console.log('Thorin Design v0.0.1');
Expand Down
1 change: 1 addition & 0 deletions packages/thorin-core/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ p {

--thorin-radius-button: 8px;
--thorin-radius-card: 16px;
--thorin-radius-tag: 14px;
}

@media (prefers-color-scheme: dark) {
Expand Down
81 changes: 81 additions & 0 deletions packages/thorin-core/src/tag/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/* eslint-disable unicorn/template-indent */
import { css, html, LitElement } from 'lit';
import { customElement, property } from 'lit/decorators.js';

type TagColorVariant =
| 'blue'
// | 'indigo'
// | 'purple'
// | 'pink'
| 'red'
// | 'orange'
| 'yellow'
| 'green'
| 'grey';

@customElement('thorin-tag')
export class ThorinTag extends LitElement {
static styles = css`
.tag.blue {
--bg: var(--thorin-blue-surface);
--color: var(--thorin-blue-primary);
}
.tag.red {
--bg: var(--thorin-red-surface);
--color: var(--thorin-red-primary);
}
.tag.yellow {
--bg: var(--thorin-yellow-surface);
--color: var(--thorin-yellow-active);
}
.tag.green {
--bg: var(--thorin-green-surface);
--color: var(--thorin-green-primary);
}
.tag.grey {
--bg: var(--thorin-grey-surface);
--color: var(--thorin-text-secondary);
}
.tag {
background: var(--bg);
color: var(--color);
display: inline-flex;
justify-content: center;
gap: 4px;
overflow: hidden;
appearance: none;
border: var(--border);
outline: none;
border-radius: var(--thorin-radius-tag);
padding: 2px 8px;
font-weight: bold;
}
`;

@property({ type: String })
variant: TagColorVariant = 'blue';

render() {
return html`
<span class="${this.computeClass}">
<slot></slot>
</span>
`;
}

private get computeClass() {
return ['tag', this.variant].join(' ').trim() || undefined;
}

private _onClick(event: PointerEvent) {
if (this.onclick) {
this.onclick(event);
}
}
}

declare global {
interface HTMLElementTagNameMap {
'thorin-tag': ThorinTag;
}
}
69 changes: 51 additions & 18 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,47 @@
<title>Thorin Design System</title>
</head>
<body>
<h1>thorin.design</h1>
<p>Welcome to the thorin design system.</p>
<div style="display: flex; flex-direction: column; gap: 4px">
<thorin-button>default button</thorin-button>
<thorin-button variant="secondary">secondary button</thorin-button>
<thorin-button variant="error-secondary">error secondary button</thorin-button>
<thorin-button variant="subtle">error secondary button</thorin-button>
<thorin-button variant="disabled">error secondary button</thorin-button>
<thorin-button variant="indigo">indigo button</thorin-button>
<thorin-button variant="purple">purple button</thorin-button>
<thorin-button variant="pink">pink button</thorin-button>
<thorin-button variant="red">red button</thorin-button>
<thorin-button variant="orange">orange button</thorin-button>
<thorin-button variant="yellow">yellow button</thorin-button>
<thorin-button variant="green">green button</thorin-button>
<thorin-button variant="grey">grey button</thorin-button>
<thorin-button>hello world</thorin-button>
<thorin-button onclick="opentestmodal()">Open Modal</thorin-button>
<div style="display: flex; flex-direction: column; gap: 4px; max-width: 765px; margin: 0 auto;">
<div class="m-width">
<div>
<h1>thorin.design</h1>
<p>Welcome to the thorin design system.</p>
</div>
</div>
<div class="card">
<thorin-button>default button</thorin-button>
<thorin-button variant="secondary"
>secondary button</thorin-button
>
<thorin-button variant="error-secondary"
>error secondary button</thorin-button
>
<thorin-button variant="subtle"
>error secondary button</thorin-button
>
<thorin-button variant="disabled"
>error secondary button</thorin-button
>
<thorin-button variant="indigo">indigo button</thorin-button>
<thorin-button variant="purple">purple button</thorin-button>
<thorin-button variant="pink">pink button</thorin-button>
<thorin-button variant="red">red button</thorin-button>
<thorin-button variant="orange">orange button</thorin-button>
<thorin-button variant="yellow">yellow button</thorin-button>
<thorin-button variant="green">green button</thorin-button>
<thorin-button variant="grey">grey button</thorin-button>
<thorin-button>hello world</thorin-button>
</div>
<div class="card">
<thorin-tag>Tag</thorin-tag>
<thorin-tag variant="green">Tag</thorin-tag>
<thorin-tag variant="red">Tag</thorin-tag>
<thorin-tag variant="yellow">Tag</thorin-tag>
<thorin-tag variant="grey">Tag</thorin-tag>
</div>
<div class="card">
<thorin-button onclick="opentestmodal()">Open Modal</thorin-button>
</div>
</div>
<thorin-modal id="testmodal">
<div class="space-y-4">
Expand Down Expand Up @@ -53,5 +76,15 @@ <h1>thorin.design</h1>
}px`;
}
</script>
<style>
.card {
display: flex;
flex-wrap: wrap;
gap: 4px;
padding: var(--thorin-spacing-4);
border: 1px solid #e5e7eb;
border-radius: var(--thorin-radius-card);
}
</style>
</body>
</html>

0 comments on commit 5be4616

Please sign in to comment.