pattern-dump 0.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +8 -0
- package/README.md +92 -0
- package/dist/dev-ui/main.css +1825 -0
- package/dist/dev-ui/main.js +3054 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +7 -0
- package/dist/pd.js +4759 -0
- package/dist/types/config/index.d.ts +145 -0
- package/dist/types/contracts/dev-protocol.d.ts +624 -0
- package/dist/types/contracts/index.d.ts +294 -0
- package/package.json +76 -0
- package/templates/base/README.md +77 -0
- package/templates/base/_gitignore +3 -0
- package/templates/base/pattern-dump.config.ts +36 -0
- package/templates/base/src/scripts/globals.d.ts +6 -0
- package/templates/base/src/styles/base/_tokens.scss +8 -0
- package/templates/base/src/styles/base/document.scss +18 -0
- package/templates/base/themes/dark.theme.scss +8 -0
- package/templates/base/themes/light.theme.scss +8 -0
- package/templates/base/tsconfig.json +19 -0
- package/templates/examples/src/patterns/atoms/button/button.hbs +1 -0
- package/templates/examples/src/patterns/atoms/button/button.json +1 -0
- package/templates/examples/src/patterns/atoms/button/button.md +21 -0
- package/templates/examples/src/patterns/atoms/button/button.schema.json +11 -0
- package/templates/examples/src/patterns/atoms/button/button~icon.hbs +5 -0
- package/templates/examples/src/patterns/atoms/button/button~secondary.json +1 -0
- package/templates/examples/src/patterns/atoms/index.md +6 -0
- package/templates/examples/src/patterns/index.md +3 -0
- package/templates/examples/src/patterns/molecules/index.md +6 -0
- package/templates/examples/src/patterns/molecules/search-field/input/input.hbs +4 -0
- package/templates/examples/src/patterns/molecules/search-field/input/input.json +1 -0
- package/templates/examples/src/patterns/molecules/search-field/input/input.md +8 -0
- package/templates/examples/src/patterns/molecules/search-field/input/input.schema.json +10 -0
- package/templates/examples/src/patterns/molecules/search-field/search-field.hbs +5 -0
- package/templates/examples/src/patterns/molecules/search-field/search-field.json +1 -0
- package/templates/examples/src/patterns/molecules/search-field/search-field.md +21 -0
- package/templates/examples/src/patterns/molecules/search-field/search-field.schema.json +11 -0
- package/templates/examples/src/patterns/pages/example/example.hbs +11 -0
- package/templates/examples/src/patterns/pages/example/example.json +8 -0
- package/templates/examples/src/patterns/pages/example/example.md +11 -0
- package/templates/examples/src/patterns/pages/example/example.schema.json +14 -0
- package/templates/examples/src/patterns/pages/index.md +6 -0
- package/templates/examples/src/scripts/search-field.ts +16 -0
- package/templates/examples/src/styles/atoms/button.scss +36 -0
- package/templates/examples/src/styles/molecules/search-field/input.scss +21 -0
- package/templates/examples/src/styles/molecules/search-field.scss +13 -0
- package/templates/examples/src/styles/pages/example.scss +28 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "inputLabel": "Search", "placeholder": "Components, tokens…", "buttonLabel": "Search" }
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Search field
|
|
3
|
+
description: A labelled search input with a submit button.
|
|
4
|
+
status: draft
|
|
5
|
+
requireScript: [search-field]
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Composes two components:
|
|
9
|
+
|
|
10
|
+
- **`atoms-button`**, included with arguments: `{{> atoms-button label=buttonLabel type="submit" }}`.
|
|
11
|
+
- **`molecules-input`**, a *private* sub-component. It lives inside this folder, is marked
|
|
12
|
+
`visibility: private`, and is hidden in the tree until internals are shown.
|
|
13
|
+
|
|
14
|
+
Both edges appear in the Inspector's **Relationships** tab.
|
|
15
|
+
|
|
16
|
+
**Behaviour** comes from `src/scripts/search-field.ts`, loaded by `requireScript: [search-field]` in
|
|
17
|
+
this file's frontmatter. Every preview that shows a search field loads it — the example page too.
|
|
18
|
+
Submit the form: the query appears in the status line instead of the preview navigating away.
|
|
19
|
+
|
|
20
|
+
```pattern molecules/search-field
|
|
21
|
+
```
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "Search field",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"required": ["inputLabel", "buttonLabel"],
|
|
6
|
+
"properties": {
|
|
7
|
+
"inputLabel": { "type": "string", "description": "Label of the search input" },
|
|
8
|
+
"placeholder": { "type": "string" },
|
|
9
|
+
"buttonLabel": { "type": "string", "description": "Text of the submit button" }
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<div class="page">
|
|
2
|
+
<header class="page-header">
|
|
3
|
+
<h1 class="page-title">{{title}}</h1>
|
|
4
|
+
{{> molecules-search-field }}
|
|
5
|
+
</header>
|
|
6
|
+
<div class="page-content">
|
|
7
|
+
<p>{{intro}}</p>
|
|
8
|
+
{{> atoms-button label=ctaLabel variant="primary" type="button" }}
|
|
9
|
+
{{> "atoms-button~secondary" }}
|
|
10
|
+
</div>
|
|
11
|
+
</div>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Example page
|
|
3
|
+
description: A full-width layout composing the search field and buttons.
|
|
4
|
+
status: draft
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
`pages` previews fill the stage (`preview: full` in `pages/index.md`). It includes a variant by its
|
|
8
|
+
quoted handle — `{{> "atoms-button~secondary" }}` — because `~` must be quoted in a partial name.
|
|
9
|
+
|
|
10
|
+
```pattern pages/example
|
|
11
|
+
```
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "Example page",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"required": ["title", "intro", "ctaLabel"],
|
|
6
|
+
"properties": {
|
|
7
|
+
"title": { "type": "string" },
|
|
8
|
+
"intro": { "type": "string" },
|
|
9
|
+
"ctaLabel": { "type": "string" },
|
|
10
|
+
"inputLabel": { "type": "string" },
|
|
11
|
+
"placeholder": { "type": "string" },
|
|
12
|
+
"buttonLabel": { "type": "string" }
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Behaviour for molecules/search-field, loaded by `requireScript: [search-field]` in its .md.
|
|
2
|
+
//
|
|
3
|
+
// Runs as a module after the markup, in every preview that shows a search field — including pages
|
|
4
|
+
// that include one. Submitting would otherwise navigate the preview away; instead the query is
|
|
5
|
+
// announced in the field's status line.
|
|
6
|
+
|
|
7
|
+
function enhance(form: HTMLFormElement): void {
|
|
8
|
+
const status = form.querySelector<HTMLElement>(".search-field-status");
|
|
9
|
+
form.addEventListener("submit", (event: SubmitEvent) => {
|
|
10
|
+
event.preventDefault();
|
|
11
|
+
const query = String(new FormData(form).get("q") ?? "").trim();
|
|
12
|
+
if (status) status.textContent = query ? `Searching for “${query}”` : "Type something to search";
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
document.querySelectorAll<HTMLFormElement>("form.search-field").forEach(enhance);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
@use "../base/tokens";
|
|
2
|
+
|
|
3
|
+
.button {
|
|
4
|
+
display: inline-flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
gap: tokens.$space-xs;
|
|
7
|
+
padding: tokens.$space-sm tokens.$space-md;
|
|
8
|
+
border: 1px solid transparent;
|
|
9
|
+
border-radius: tokens.$radius;
|
|
10
|
+
font: inherit;
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.button:focus-visible {
|
|
15
|
+
outline: 2px solid var(--color-primary, #0b5cad);
|
|
16
|
+
outline-offset: 2px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.button-primary {
|
|
20
|
+
background: var(--color-primary, #0b5cad);
|
|
21
|
+
color: var(--color-on-primary, #ffffff);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.button-secondary {
|
|
25
|
+
background: transparent;
|
|
26
|
+
border-color: var(--color-border, #6b7280);
|
|
27
|
+
color: var(--color-text, #1b1b1f);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.button-icon {
|
|
31
|
+
padding: tokens.$space-sm;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.button-glyph {
|
|
35
|
+
display: block;
|
|
36
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
@use "../../base/tokens";
|
|
2
|
+
|
|
3
|
+
.input {
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
gap: tokens.$space-xs;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.input-label {
|
|
10
|
+
font-size: 0.875rem;
|
|
11
|
+
color: var(--color-text-muted, #4b5563);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.input-control {
|
|
15
|
+
padding: tokens.$space-sm;
|
|
16
|
+
border: 1px solid var(--color-border, #6b7280);
|
|
17
|
+
border-radius: tokens.$radius;
|
|
18
|
+
font: inherit;
|
|
19
|
+
color: inherit;
|
|
20
|
+
background: var(--color-surface, #ffffff);
|
|
21
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
@use "../base/tokens";
|
|
2
|
+
|
|
3
|
+
.page-header {
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-wrap: wrap;
|
|
6
|
+
align-items: flex-end;
|
|
7
|
+
justify-content: space-between;
|
|
8
|
+
gap: tokens.$space-md;
|
|
9
|
+
padding: tokens.$space-lg;
|
|
10
|
+
border-bottom: 1px solid var(--color-border, #6b7280);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.page-title {
|
|
14
|
+
margin: 0;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.page-content {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-wrap: wrap;
|
|
20
|
+
align-items: center;
|
|
21
|
+
gap: tokens.$space-md;
|
|
22
|
+
padding: tokens.$space-lg;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.page-content p {
|
|
26
|
+
flex-basis: 100%;
|
|
27
|
+
margin: 0;
|
|
28
|
+
}
|