Skip to content

Commit

Permalink
Introduce Label
Browse files Browse the repository at this point in the history
  • Loading branch information
lucemans committed Feb 15, 2024
1 parent 5be4616 commit b9d4235
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/thorin-core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export { ThorinAvatar } from './avatar';
export { ThorinButton } from './button';
export { ThorinLabel } from './label';
export { ThorinModal } from './modal';
export { ThorinTag } from './tag';

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

type LabelVariant = 'default' | 'active' | 'helper';

@customElement('thorin-label')
export class ThorinLabel extends LitElement {
static styles = css`
.label.default {
--color: var(--thorin-text-secondary);
--border: 1px solid var(--thorin-border);
}
.label.active {
--bg: var(--thorin-blue-surface);
--color: var(--thorin-blue-primary);
--border: 1px solid var(--thorin-blue-surface);
}
.label.helper {
--color: var(--thorin-indigo-primary);
--border: 1px solid var(--thorin-border);
text-decoration: underline;
}
.label {
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-label);
padding: 4px 8px;
font-weight: bold;
}
`;

@property({ type: String })
variant: LabelVariant = 'default';

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

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

declare global {
interface HTMLElementTagNameMap {
'thorin-label': ThorinLabel;
}
}
1 change: 1 addition & 0 deletions packages/thorin-core/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ p {
--thorin-radius-button: 8px;
--thorin-radius-card: 16px;
--thorin-radius-tag: 14px;
--thorin-radius-label: 4px;
}

@media (prefers-color-scheme: dark) {
Expand Down
6 changes: 0 additions & 6 deletions packages/thorin-core/src/tag/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ export class ThorinTag extends LitElement {
private get computeClass() {
return ['tag', this.variant].join(' ').trim() || undefined;
}

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

declare global {
Expand Down
5 changes: 5 additions & 0 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ <h1>thorin.design</h1>
<thorin-tag variant="yellow">Tag</thorin-tag>
<thorin-tag variant="grey">Tag</thorin-tag>
</div>
<div class="card">
<thorin-label>Label</thorin-label>
<thorin-label variant="active">Label</thorin-label>
<thorin-label variant="helper">Label</thorin-label>
</div>
<div class="card">
<thorin-button onclick="opentestmodal()">Open Modal</thorin-button>
</div>
Expand Down

0 comments on commit b9d4235

Please sign in to comment.