Skip to content

Commit 65cb472

Browse files
Tweets recipe (#232)
* Add gaps to vstack/hstack * Get icons working * remove unused .js and .d.ts files in shoelace components ...we use .ts instead * Add tweets recipe
1 parent 2b1bcad commit 65cb472

File tree

9 files changed

+169
-542
lines changed

9 files changed

+169
-542
lines changed
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
import { LitElement, html, css } from "lit";
22
import { customElement } from "lit/decorators.js";
3-
import { view } from '../hyperscript/render.js';
3+
import { view } from "../hyperscript/render.js";
44
import { baseStyles } from "./style.js";
55

6-
export const hstack = view('common-hstack', {});
6+
export const hstack = view("common-hstack", {});
77

88
@customElement("common-hstack")
99
export class CommonHstackElement extends LitElement {
1010
static override styles = [
1111
baseStyles,
1212
css`
13-
:host {
14-
display: block;
15-
}
13+
:host {
14+
display: block;
15+
}
1616
17-
.stack {
18-
display: flex;
19-
flex-direction: row;
20-
}
17+
.hstack {
18+
display: flex;
19+
flex-direction: row;
20+
align-items: center;
21+
}
2122
22-
:host([gap="md"]) .stack {
23-
gap: var(--gap);
24-
}
23+
:host([gap="md"]) .hstack {
24+
gap: var(--gap);
25+
}
2526
26-
:host([pad="md"]) .stack {
27-
padding: var(--gap);
28-
}
29-
`
27+
:host([pad="md"]) .hstack {
28+
padding: var(--gap);
29+
}
30+
`,
3031
];
3132

3233
override render() {
33-
return html`
34-
<div class="stack">
34+
return html` <div class="hstack">
3535
<slot></slot>
3636
</div>`;
3737
}
38-
}
38+
}
Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,51 @@
11
import { LitElement, html, css } from "lit";
22
import { customElement } from "lit/decorators.js";
33
import { baseStyles } from "./style.js";
4-
import { view } from '../hyperscript/render.js';
4+
import { view } from "../hyperscript/render.js";
55
import { eventProps } from "../hyperscript/schema-helpers.js";
66

7-
export const vstack = view('common-vstack', {
7+
export const vstack = view("common-vstack", {
88
...eventProps(),
9-
gap: { type: 'string' },
10-
pad: { type: 'string' }
9+
gap: { type: "string" },
10+
pad: { type: "string" },
1111
});
1212

1313
@customElement("common-vstack")
1414
export class CommonVstackElement extends LitElement {
1515
static override styles = [
1616
baseStyles,
1717
css`
18-
:host {
19-
display: block;
20-
}
21-
22-
.stack {
23-
display: flex;
24-
flex-direction: column;
25-
gap: var(--pad);
26-
27-
}
28-
29-
:host([gap="none"]) .stack {
30-
gap: 0;
31-
}
32-
33-
:host([gap="sm"]) .stack {
34-
gap: var(--pad-sm);
35-
}
36-
37-
:host([pad="md"]) .stack {
38-
padding: var(--pad);
39-
}
40-
`
18+
:host {
19+
display: block;
20+
}
21+
22+
.stack {
23+
display: flex;
24+
flex-direction: column;
25+
gap: var(--pad);
26+
}
27+
28+
:host([gap="none"]) .stack {
29+
gap: 0;
30+
}
31+
32+
:host([gap="sm"]) .stack {
33+
gap: var(--pad-sm);
34+
}
35+
36+
:host([gap="md"]) .stack {
37+
gap: var(--pad);
38+
}
39+
40+
:host([pad="md"]) .stack {
41+
padding: var(--pad);
42+
}
43+
`,
4144
];
4245

4346
override render() {
44-
return html`
45-
<div class="stack">
47+
return html` <div class="stack">
4648
<slot></slot>
4749
</div>`;
4850
}
49-
}
51+
}

typescript/packages/common-ui/src/components/shoelace/index.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export * from "./components.js";
22
import theme from "./theme/light.styles.js";
3+
import { registerIconLibrary } from "@shoelace-style/shoelace";
34

45
/**
56
* Adopt the styles for shoelace components.
@@ -11,3 +12,22 @@ export const adoptShoelaceStyles = (
1112
) => {
1213
host.adoptedStyleSheets = [theme.styleSheet];
1314
};
15+
16+
export const registerShoelaceIcons = () => {
17+
registerIconLibrary("material", {
18+
resolver: (name) => {
19+
const match = name.match(/^(.*?)(_(round|sharp))?$/);
20+
return `https://cdn.jsdelivr.net/npm/@material-icons/svg@1.0.5/svg/${match[1]}/${match[3] || "outline"}.svg`;
21+
},
22+
mutator: (svg) => svg.setAttribute("fill", "currentColor"),
23+
});
24+
};
25+
26+
export const setupShoelace = ({
27+
host = window.document,
28+
}: {
29+
host?: Document | ShadowRoot;
30+
} = {}) => {
31+
registerShoelaceIcons();
32+
adoptShoelaceStyles(host);
33+
};

typescript/packages/common-ui/src/components/shoelace/theme/light.styles.d.ts

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

0 commit comments

Comments
 (0)