Skip to content

A platform for community discussion. Free, open, simple.

DEV: Source the remaining styleguide code samples from real modules (#42139)

Sérgio Saquetimbdcc4f6c983c
diff --git a/plugins/styleguide/README.md b/plugins/styleguide/README.md
index 4ebea0fa083..208a04a3037 100644
--- a/plugins/styleguide/README.md
+++ b/plugins/styleguide/README.md
@@ -5,7 +5,7 @@ configurations to aid in styling.
![Screenshot](screenshot.png)
-## Automatic code examples
+## Code examples
Discourse's build pipeline allows adding `?source=file` or `?source=template` to
a module import. This provides a string of the raw source code for the entire
@@ -14,12 +14,12 @@ file, or just for the `<template>`. Put the example in its own module under
```gjs
import StyleguideExample from "discourse/plugins/styleguide/discourse/components/styleguide-example";
-import CharCounterExample from "../../examples/char-counter";
-import charCounterSource from "../../examples/char-counter.gjs?source=file";
+import CharCounterExample from "../../examples/molecules/char-counter";
+import charCounterSource from "../../examples/molecules/char-counter?source=file";
export default <template>
<StyleguideExample @title="<DCharCounter>" @code={{charCounterSource}}>
- <CharCounterExample @dummy={{@dummy}} />
+ <CharCounterExample />
</StyleguideExample>
</template>
```
@@ -27,5 +27,42 @@ export default <template>
The import must resolve within the same plugin or theme bundle, and
`?source=template` requires the module to contain exactly one `<template>`.
-Keep using an explicit `@code` string for curated samples that intentionally
-differ from the rendered implementation.
+### Criteria
+
+Samples typed by hand drift from the code they describe. These rules keep that
+from being possible.
+
+1. Every `<StyleguideExample>` that passes `@code` passes a `?source=` import,
+ never a hand-written string.
+
+2. Each example is its own module under `examples/`. A module may back several
+ examples when the variants differ only in the data passed in.
+
+3. Use `?source=file` when the module has imports or JS, so the reader sees
+ what to paste into a new file. Use `?source=template` when it is pure markup.
+
+4. The example module holds only the API being taught. Styleguide-only chrome
+ stays in the section file, wrapping the example.
+
+5. An example receives only what it cannot build itself. Store-backed records
+ come in as named args; literal fixtures, state and callbacks the example
+ owns. Examples never take `@dummy` itself.
+
+6. An example demonstrating a design token, a color or a type scale does not
+ need `@code` at all.
+
+7. A hand-written `@code` string is admissible only when the sample cannot be a
+ module that renders on this page: it is computed from the page's live
+ controls, or the block is a gallery rather than a usage example. It must
+ carry a comment saying which.
+
+### Layout
+
+```
+examples/<group>/<section>/<name>.gjs
+```
+
+`<group>` is `atoms`, `molecules` or `organisms`; `<section>` is the section
+file name without its numeric prefix; `<name>` is a kebab-case slug for the
+variant. Import with a relative specifier and no file extension, and name the
+bindings `<Name>Example` and `<name>Source`.
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/danger-sizes.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/danger-sizes.gjs
new file mode 100644
index 00000000000..b157126f0ba
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/danger-sizes.gjs
@@ -0,0 +1,15 @@
+import DButton from "discourse/ui-kit/d-button";
+
+export default <template>
+ <DButton
+ @icon="trash-can"
+ @translatedLabel="large"
+ class="btn-danger btn-large"
+ />
+ <DButton @icon="trash-can" @translatedLabel="default" class="btn-danger" />
+ <DButton
+ @icon="trash-can"
+ @translatedLabel="small"
+ class="btn-danger btn-small"
+ />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/danger-states.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/danger-states.gjs
new file mode 100644
index 00000000000..19897207ed8
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/danger-states.gjs
@@ -0,0 +1,16 @@
+import DButton from "discourse/ui-kit/d-button";
+
+export default <template>
+ <DButton @icon="trash-can" @translatedLabel="normal" class="btn-danger" />
+ <DButton
+ @icon="trash-can"
+ @translatedLabel="hover"
+ class="btn-danger btn-hover"
+ />
+ <DButton
+ @icon="trash-can"
+ @translatedLabel="disabled"
+ @disabled={{true}}
+ class="btn-danger"
+ />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/flat-sizes.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/flat-sizes.gjs
new file mode 100644
index 00000000000..ebb832ec091
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/flat-sizes.gjs
@@ -0,0 +1,15 @@
+import DButton from "discourse/ui-kit/d-button";
+
+export default <template>
+ <DButton
+ @icon="trash-can"
+ @translatedTitle="large"
+ class="btn-flat btn-large"
+ />
+ <DButton @icon="trash-can" @translatedTitle="default" class="btn-flat" />
+ <DButton
+ @icon="trash-can"
+ @translatedTitle="small"
+ class="btn-flat btn-small"
+ />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/flat-states.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/flat-states.gjs
new file mode 100644
index 00000000000..cbc7282db2a
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/flat-states.gjs
@@ -0,0 +1,16 @@
+import DButton from "discourse/ui-kit/d-button";
+
+export default <template>
+ <DButton @icon="trash-can" @translatedLabel="normal" class="btn-flat" />
+ <DButton
+ @icon="trash-can"
+ @translatedLabel="hover"
+ class="btn-flat btn-hover"
+ />
+ <DButton
+ @icon="trash-can"
+ @translatedLabel="disabled"
+ @disabled={{true}}
+ class="btn-flat"
+ />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/icon-sizes.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/icon-sizes.gjs
new file mode 100644
index 00000000000..9acf8e34978
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/icon-sizes.gjs
@@ -0,0 +1,15 @@
+import DButton from "discourse/ui-kit/d-button";
+
+export default <template>
+ <DButton
+ @icon="xmark"
+ @translatedTitle="large"
+ class="btn-default btn-large"
+ />
+ <DButton @icon="xmark" @translatedTitle="default" class="btn-default" />
+ <DButton
+ @icon="xmark"
+ @translatedTitle="small"
+ class="btn-default btn-small"
+ />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/icon-states.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/icon-states.gjs
new file mode 100644
index 00000000000..8bb856f78af
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/icon-states.gjs
@@ -0,0 +1,16 @@
+import DButton from "discourse/ui-kit/d-button";
+
+export default <template>
+ <DButton @icon="xmark" @translatedTitle="normal" class="btn-default" />
+ <DButton
+ @icon="xmark"
+ @translatedTitle="hover"
+ class="btn-default btn-hover"
+ />
+ <DButton
+ @icon="xmark"
+ @translatedTitle="disabled"
+ @disabled={{true}}
+ class="btn-default"
+ />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/icon-text-sizes.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/icon-text-sizes.gjs
new file mode 100644
index 00000000000..3e76186ddd1
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/icon-text-sizes.gjs
@@ -0,0 +1,15 @@
+import DButton from "discourse/ui-kit/d-button";
+
+export default <template>
+ <DButton
+ @icon="plus"
+ @translatedLabel="large"
+ class="btn-default btn-large"
+ />
+ <DButton @icon="plus" @translatedLabel="default" class="btn-default" />
+ <DButton
+ @icon="plus"
+ @translatedLabel="small"
+ class="btn-default btn-small"
+ />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/icon-text-states.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/icon-text-states.gjs
new file mode 100644
index 00000000000..bdb7ca8f09f
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/icon-text-states.gjs
@@ -0,0 +1,16 @@
+import DButton from "discourse/ui-kit/d-button";
+
+export default <template>
+ <DButton @icon="plus" @translatedLabel="normal" class="btn-default" />
+ <DButton
+ @icon="plus"
+ @translatedLabel="hover"
+ class="btn-default btn-hover"
+ />
+ <DButton
+ @icon="plus"
+ @translatedLabel="disabled"
+ @disabled={{true}}
+ class="btn-default"
+ />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/link.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/link.gjs
new file mode 100644
index 00000000000..56994485b3e
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/link.gjs
@@ -0,0 +1,17 @@
+import DButton from "discourse/ui-kit/d-button";
+
+export default <template>
+ <DButton @icon="trash-can" @translatedLabel="normal" @display="link" />
+ <DButton
+ @icon="trash-can"
+ @translatedLabel="hover"
+ @display="link"
+ class="btn-hover"
+ />
+ <DButton
+ @icon="trash-can"
+ @translatedLabel="disabled"
+ @display="link"
+ @disabled={{true}}
+ />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/primary-sizes.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/primary-sizes.gjs
new file mode 100644
index 00000000000..37e601a4a59
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/primary-sizes.gjs
@@ -0,0 +1,15 @@
+import DButton from "discourse/ui-kit/d-button";
+
+export default <template>
+ <DButton
+ @icon="plus"
+ @translatedLabel="large"
+ class="btn-primary btn-large"
+ />
+ <DButton @icon="plus" @translatedLabel="default" class="btn-primary" />
+ <DButton
+ @icon="plus"
+ @translatedLabel="small"
+ class="btn-primary btn-small"
+ />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/primary-states.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/primary-states.gjs
new file mode 100644
index 00000000000..ba8a4db84d3
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/primary-states.gjs
@@ -0,0 +1,16 @@
+import DButton from "discourse/ui-kit/d-button";
+
+export default <template>
+ <DButton @icon="plus" @translatedLabel="normal" class="btn-primary" />
+ <DButton
+ @icon="plus"
+ @translatedLabel="hover"
+ class="btn-primary btn-hover"
+ />
+ <DButton
+ @icon="plus"
+ @translatedLabel="disabled"
+ @disabled={{true}}
+ class="btn-primary"
+ />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/text-sizes.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/text-sizes.gjs
new file mode 100644
index 00000000000..934d79847b8
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/text-sizes.gjs
@@ -0,0 +1,7 @@
+import DButton from "discourse/ui-kit/d-button";
+
+export default <template>
+ <DButton @translatedLabel="large" class="btn-default btn-large" />
+ <DButton @translatedLabel="default" class="btn-default" />
+ <DButton @translatedLabel="small" class="btn-default btn-small" />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/text-states.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/text-states.gjs
new file mode 100644
index 00000000000..268058cd7b7
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/text-states.gjs
@@ -0,0 +1,7 @@
+import DButton from "discourse/ui-kit/d-button";
+
+export default <template>
+ <DButton @translatedLabel="normal" class="btn-default" />
+ <DButton @translatedLabel="hover" class="btn-default btn-hover" />
+ <DButton @translatedLabel="disabled" @disabled={{true}} class="btn-default" />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/toggle-switch.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/toggle-switch.gjs
new file mode 100644
index 00000000000..9fafeafebb6
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/toggle-switch.gjs
@@ -0,0 +1,28 @@
+import Component from "@glimmer/component";
+import { tracked } from "@glimmer/tracking";
+import { on } from "@ember/modifier";
+import { action } from "@ember/object";
+import DToggleSwitch from "discourse/ui-kit/d-toggle-switch";
+
+export default class ToggleSwitchExample extends Component {
+ @tracked state = true;
+
+ @action
+ toggle() {
+ this.state = !this.state;
+ }
+
+ <template>
+ <DToggleSwitch @state={{this.state}} {{on "click" this.toggle}} />
+ <DToggleSwitch
+ disabled="true"
+ @state={{true}}
+ title="Disabled with state=true"
+ />
+ <DToggleSwitch
+ disabled="true"
+ @state={{false}}
+ title="Disabled with state=false"
+ />
+ </template>
+}
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/transparent-states.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/transparent-states.gjs
new file mode 100644
index 00000000000..c477647f5c6
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/buttons/transparent-states.gjs
@@ -0,0 +1,20 @@
+import DButton from "discourse/ui-kit/d-button";
+
+export default <template>
+ <DButton
+ @icon="trash-can"
+ @translatedLabel="normal"
+ class="btn-transparent"
+ />
+ <DButton
+ @icon="trash-can"
+ @translatedLabel="hover"
+ class="btn-transparent btn-hover"
+ />
+ <DButton
+ @icon="trash-can"
+ @translatedLabel="disabled"
+ @disabled={{true}}
+ class="btn-transparent"
+ />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/date-time-inputs/calendar-date-time-input.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/date-time-inputs/calendar-date-time-input.gjs
new file mode 100644
index 00000000000..416a2b2fa3b
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/date-time-inputs/calendar-date-time-input.gjs
@@ -0,0 +1,14 @@
+import DCalendarDateTimeInput from "discourse/ui-kit/d-calendar-date-time-input";
+
+export default <template>
+ <DCalendarDateTimeInput
+ @datePickerId="styleguide"
+ @date={{@date}}
+ @time={{@time}}
+ @minDate={{@minDate}}
+ @dateFormat="YYYY-MM-DD"
+ @timeFormat="HH:mm:ss"
+ @onChangeDate={{@onChangeDate}}
+ @onChangeTime={{@onChangeTime}}
+ />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/date-time-inputs/date-input.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/date-time-inputs/date-input.gjs
new file mode 100644
index 00000000000..4455884f2dd
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/date-time-inputs/date-input.gjs
@@ -0,0 +1,3 @@
+import DDateInput from "discourse/ui-kit/d-date-input";
+
+export default <template><DDateInput /></template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/date-time-inputs/date-picker.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/date-time-inputs/date-picker.gjs
new file mode 100644
index 00000000000..95db8b711b0
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/date-time-inputs/date-picker.gjs
@@ -0,0 +1,3 @@
+import DDatePicker from "discourse/ui-kit/d-date-picker";
+
+export default <template><DDatePicker @defaultDate="YYYY-MM-DD" /></template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/date-time-inputs/date-time-input-range-without-time.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/date-time-inputs/date-time-input-range-without-time.gjs
new file mode 100644
index 00000000000..1d8c3962b85
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/date-time-inputs/date-time-input-range-without-time.gjs
@@ -0,0 +1,5 @@
+import DDateTimeInputRange from "discourse/ui-kit/d-date-time-input-range";
+
+export default <template>
+ <DDateTimeInputRange @showFromTime={{false}} @showToTime={{false}} />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/date-time-inputs/date-time-input-range.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/date-time-inputs/date-time-input-range.gjs
new file mode 100644
index 00000000000..fb836c22853
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/date-time-inputs/date-time-input-range.gjs
@@ -0,0 +1,3 @@
+import DDateTimeInputRange from "discourse/ui-kit/d-date-time-input-range";
+
+export default <template><DDateTimeInputRange /></template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/date-time-inputs/date-time-input.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/date-time-inputs/date-time-input.gjs
new file mode 100644
index 00000000000..eab29480dce
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/date-time-inputs/date-time-input.gjs
@@ -0,0 +1,3 @@
+import DDateTimeInput from "discourse/ui-kit/d-date-time-input";
+
+export default <template><DDateTimeInput @clearable={{true}} /></template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/date-time-inputs/future-date-input.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/date-time-inputs/future-date-input.gjs
new file mode 100644
index 00000000000..f74636e5fce
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/date-time-inputs/future-date-input.gjs
@@ -0,0 +1,5 @@
+import DFutureDateInput from "discourse/ui-kit/d-future-date-input";
+
+export default <template>
+ <DFutureDateInput @displayLabelIcon="far-clock" @clearable={{true}} />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/date-time-inputs/time-input.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/date-time-inputs/time-input.gjs
new file mode 100644
index 00000000000..82c1bae93d2
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/date-time-inputs/time-input.gjs
@@ -0,0 +1,3 @@
+import DTimeInput from "discourse/ui-kit/d-time-input";
+
+export default <template><DTimeInput /></template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/categories-admin-dropdown.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/categories-admin-dropdown.gjs
new file mode 100644
index 00000000000..d057a690751
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/categories-admin-dropdown.gjs
@@ -0,0 +1,5 @@
+import CategoriesAdminDropdown from "discourse/select-kit/components/categories-admin-dropdown";
+
+export default <template>
+ <CategoriesAdminDropdown @onChange={{@onChange}} />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/category-chooser.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/category-chooser.gjs
new file mode 100644
index 00000000000..8c69c20e84d
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/category-chooser.gjs
@@ -0,0 +1,17 @@
+import Component from "@glimmer/component";
+import { tracked } from "@glimmer/tracking";
+import { action } from "@ember/object";
+import CategoryChooser from "discourse/select-kit/components/category-chooser";
+
+export default class CategoryChooserExample extends Component {
+ @tracked value = null;
+
+ @action
+ onChange(value) {
+ this.value = value;
+ }
+
+ <template>
+ <CategoryChooser @value={{this.value}} @onChange={{this.onChange}} />
+ </template>
+}
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/category-notifications-tracking.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/category-notifications-tracking.gjs
new file mode 100644
index 00000000000..2a99e74ca1e
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/category-notifications-tracking.gjs
@@ -0,0 +1,5 @@
+import CategoryNotificationsTracking from "discourse/components/category-notifications-tracking";
+
+export default <template>
+ <CategoryNotificationsTracking @levelId={{1}} @onChange={{@onChange}} />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/combo-box-clearable.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/combo-box-clearable.gjs
new file mode 100644
index 00000000000..89ce090af1b
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/combo-box-clearable.gjs
@@ -0,0 +1,31 @@
+import Component from "@glimmer/component";
+import { tracked } from "@glimmer/tracking";
+import { hash } from "@ember/helper";
+import { action } from "@ember/object";
+import ComboBox from "discourse/select-kit/components/combo-box";
+
+const OPTIONS = [
+ { id: 1, name: "Orange" },
+ { id: 2, name: "Blue" },
+ { id: 3, name: "Red" },
+ { id: 4, name: "Yellow" },
+];
+
+export default class ComboBoxClearableExample extends Component {
+ @tracked value = OPTIONS[0].name;
+
+ @action
+ onChange(value) {
+ this.value = value;
+ }
+
+ <template>
+ <ComboBox
+ @content={{OPTIONS}}
+ @clearable={{true}}
+ @value={{this.value}}
+ @options={{hash none="category.none"}}
+ @onChange={{this.onChange}}
+ />
+ </template>
+}
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/combo-box-filterable.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/combo-box-filterable.gjs
new file mode 100644
index 00000000000..6c9c5f51b84
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/combo-box-filterable.gjs
@@ -0,0 +1,23 @@
+import Component from "@glimmer/component";
+import { tracked } from "@glimmer/tracking";
+import { hash } from "@ember/helper";
+import { action } from "@ember/object";
+import ComboBox from "discourse/select-kit/components/combo-box";
+
+export default class ComboBoxFilterableExample extends Component {
+ @tracked value = this.args.categories?.[0]?.name;
+
+ @action
+ onChange(value) {
+ this.value = value;
+ }
+
+ <template>
+ <ComboBox
+ @content={{@categories}}
+ @value={{this.value}}
+ @options={{hash filterable=true}}
+ @onChange={{this.onChange}}
+ />
+ </template>
+}
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/combo-box-none.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/combo-box-none.gjs
new file mode 100644
index 00000000000..19597bc27bd
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/combo-box-none.gjs
@@ -0,0 +1,30 @@
+import Component from "@glimmer/component";
+import { tracked } from "@glimmer/tracking";
+import { hash } from "@ember/helper";
+import { action } from "@ember/object";
+import ComboBox from "discourse/select-kit/components/combo-box";
+
+const OPTIONS = [
+ { id: 1, name: "Orange" },
+ { id: 2, name: "Blue" },
+ { id: 3, name: "Red" },
+ { id: 4, name: "Yellow" },
+];
+
+export default class ComboBoxNoneExample extends Component {
+ @tracked value = OPTIONS[0].name;
+
+ @action
+ onChange(value) {
+ this.value = value;
+ }
+
+ <template>
+ <ComboBox
+ @content={{OPTIONS}}
+ @value={{this.value}}
+ @options={{hash none="category.none"}}
+ @onChange={{this.onChange}}
+ />
+ </template>
+}
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/combo-box.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/combo-box.gjs
new file mode 100644
index 00000000000..9f3931ef643
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/combo-box.gjs
@@ -0,0 +1,28 @@
+import Component from "@glimmer/component";
+import { tracked } from "@glimmer/tracking";
+import { action } from "@ember/object";
+import ComboBox from "discourse/select-kit/components/combo-box";
+
+const OPTIONS = [
+ { id: 1, name: "Orange" },
+ { id: 2, name: "Blue" },
+ { id: 3, name: "Red" },
+ { id: 4, name: "Yellow" },
+];
+
+export default class ComboBoxExample extends Component {
+ @tracked value = OPTIONS[0].name;
+
+ @action
+ onChange(value) {
+ this.value = value;
+ }
+
+ <template>
+ <ComboBox
+ @content={{OPTIONS}}
+ @value={{this.value}}
+ @onChange={{this.onChange}}
+ />
+ </template>
+}
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/dropdown-select-box.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/dropdown-select-box.gjs
new file mode 100644
index 00000000000..35fddb5bb73
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/dropdown-select-box.gjs
@@ -0,0 +1,17 @@
+import { hash } from "@ember/helper";
+import DropdownSelectBox from "discourse/select-kit/components/dropdown-select-box";
+
+const OPTIONS = [
+ { id: 1, name: "Orange" },
+ { id: 2, name: "Blue" },
+ { id: 3, name: "Red" },
+ { id: 4, name: "Yellow" },
+];
+
+export default <template>
+ <DropdownSelectBox
+ @content={{OPTIONS}}
+ @onChange={{@onChange}}
+ @options={{hash translatedNone="Something"}}
+ />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/future-date-input-selector.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/future-date-input-selector.gjs
new file mode 100644
index 00000000000..f0a4a390a5f
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/future-date-input-selector.gjs
@@ -0,0 +1,11 @@
+import { hash } from "@ember/helper";
+import FutureDateInputSelector from "discourse/select-kit/components/future-date-input-selector";
+
+export default <template>
+ <FutureDateInputSelector
+ @input="2017-10-18 18:00"
+ @includeWeekend={{true}}
+ @includeForever={{true}}
+ @options={{hash none="time_shortcut.select_timeframe"}}
+ />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/group-chooser.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/group-chooser.gjs
new file mode 100644
index 00000000000..379a5740a1b
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/group-chooser.gjs
@@ -0,0 +1,17 @@
+import GroupChooser from "discourse/select-kit/components/group-chooser";
+
+const GROUPS = [
+ { name: "staff", id: 1, automatic: false },
+ { name: "lounge", id: 2, automatic: true },
+ { name: "admin", id: 3, automatic: false },
+];
+
+const SELECTED = [1, 2];
+
+export default <template>
+ <GroupChooser
+ @selected={{SELECTED}}
+ @content={{GROUPS}}
+ @onChange={{@onChange}}
+ />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/icon-grid-picker.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/icon-grid-picker.gjs
new file mode 100644
index 00000000000..77613951957
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/icon-grid-picker.gjs
@@ -0,0 +1,3 @@
+import DIconGridPicker from "discourse/ui-kit/d-icon-grid-picker";
+
+export default <template><DIconGridPicker /></template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/list-setting-name-property.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/list-setting-name-property.gjs
new file mode 100644
index 00000000000..b9019245cb7
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/list-setting-name-property.gjs
@@ -0,0 +1,9 @@
+import ListSetting from "discourse/select-kit/components/list-setting";
+
+export default <template>
+ <ListSetting
+ @settingValue="f49|c89|564897"
+ @nameProperty="color"
+ @onChange={{@onChange}}
+ />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/list-setting.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/list-setting.gjs
new file mode 100644
index 00000000000..77778d59a36
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/list-setting.gjs
@@ -0,0 +1,8 @@
+import ListSetting from "discourse/select-kit/components/list-setting";
+
+export default <template>
+ <ListSetting
+ @settingValue="bold|italic|strike|underline"
+ @onChange={{@onChange}}
+ />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/mini-tag-chooser-header-filter.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/mini-tag-chooser-header-filter.gjs
new file mode 100644
index 00000000000..0fcebb61d99
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/mini-tag-chooser-header-filter.gjs
@@ -0,0 +1,15 @@
+import { hash } from "@ember/helper";
+import MiniTagChooser from "discourse/select-kit/components/mini-tag-chooser";
+
+const TAGS = ["apple", "orange", "potato"];
+
+export default <template>
+ <MiniTagChooser
+ @value={{TAGS}}
+ @options={{hash
+ filterable=true
+ filterPlaceholder="tagging.choose_for_topic"
+ useHeaderFilter=true
+ }}
+ />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/mini-tag-chooser.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/mini-tag-chooser.gjs
new file mode 100644
index 00000000000..32aa23f52be
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/mini-tag-chooser.gjs
@@ -0,0 +1,8 @@
+import { hash } from "@ember/helper";
+import MiniTagChooser from "discourse/select-kit/components/mini-tag-chooser";
+
+const TAGS = ["apple", "orange", "potato"];
+
+export default <template>
+ <MiniTagChooser @value={{TAGS}} @options={{hash filterable=true}} />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/multi-select.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/multi-select.gjs
new file mode 100644
index 00000000000..beee3184e6b
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/multi-select.gjs
@@ -0,0 +1,12 @@
+import MultiSelect from "discourse/select-kit/components/multi-select";
+
+const OPTIONS = [
+ { id: 1, name: "Orange" },
+ { id: 2, name: "Blue" },
+ { id: 3, name: "Red" },
+ { id: 4, name: "Yellow" },
+];
+
+export default <template>
+ <MultiSelect @content={{OPTIONS}} @onChange={{@onChange}} />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/pinned-button.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/pinned-button.gjs
new file mode 100644
index 00000000000..9d6162d75d8
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/pinned-button.gjs
@@ -0,0 +1,5 @@
+import PinnedButton from "discourse/components/pinned-button";
+
+export default <template>
+ <PinnedButton @topic={{@topic}} @pinned={{true}} />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/pinned-options.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/pinned-options.gjs
new file mode 100644
index 00000000000..c12563c0f6c
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/pinned-options.gjs
@@ -0,0 +1,3 @@
+import PinnedOptions from "discourse/components/pinned-options";
+
+export default <template><PinnedOptions @topic={{@topic}} /></template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/topic-notifications-tracking.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/topic-notifications-tracking.gjs
new file mode 100644
index 00000000000..8df3fe53e6e
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/topic-notifications-tracking.gjs
@@ -0,0 +1,20 @@
+import Component from "@glimmer/component";
+import { tracked } from "@glimmer/tracking";
+import { action } from "@ember/object";
+import TopicNotificationsTracking from "discourse/components/topic-notifications-tracking";
+
+export default class TopicNotificationsTrackingExample extends Component {
+ @tracked levelId = 1;
+
+ @action
+ onChange(levelId) {
+ this.levelId = levelId;
+ }
+
+ <template>
+ <TopicNotificationsTracking
+ @levelId={{this.levelId}}
+ @onChange={{this.onChange}}
+ />
+ </template>
+}
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/user-notifications-dropdown.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/user-notifications-dropdown.gjs
new file mode 100644
index 00000000000..5bc3e25717a
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/dropdowns/user-notifications-dropdown.gjs
@@ -0,0 +1,14 @@
+import Component from "@glimmer/component";
+import { service } from "@ember/service";
+import UserNotificationsDropdown from "discourse/select-kit/components/user-notifications-dropdown";
+
+export default class UserNotificationsDropdownExample extends Component {
+ @service currentUser;
+
+ <template>
+ <UserNotificationsDropdown
+ @user={{this.currentUser}}
+ @value="changeToNormal"
+ />
+ </template>
+}
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/alert.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/alert.gjs
new file mode 100644
index 00000000000..cf6254aa237
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/alert.gjs
@@ -0,0 +1,9 @@
+import Form from "discourse/components/form";
+
+export default <template>
+ <Form as |form|>
+ <form.Alert @icon="pencil">
+ You can edit this form.
+ </form.Alert>
+ </Form>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/checkbox-group.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/checkbox-group.gjs
new file mode 100644
index 00000000000..9d3cbd9825e
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/checkbox-group.gjs
@@ -0,0 +1,24 @@
+import Form from "discourse/components/form";
+
+export default <template>
+ <Form as |form|>
+ <form.CheckboxGroup @title="I give explicit permission" as |checkboxGroup|>
+ <checkboxGroup.Field
+ @title="Use my email for any purpose."
+ @name="contract"
+ @type="checkbox"
+ as |field|
+ >
+ <field.Control>Including signing up for services I can't unsubscribe to.</field.Control>
+ </checkboxGroup.Field>
+ <checkboxGroup.Field
+ @title="Sign my soul away."
+ @name="contract2"
+ @type="checkbox"
+ as |field|
+ >
+ <field.Control>Will severly impact the afterlife experience.</field.Control>
+ </checkboxGroup.Field>
+ </form.CheckboxGroup>
+ </Form>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/code.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/code.gjs
new file mode 100644
index 00000000000..68f4b2a6891
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/code.gjs
@@ -0,0 +1,9 @@
+import Form from "discourse/components/form";
+
+export default <template>
+ <Form as |form|>
+ <form.Field @title="Query" @name="query" @type="code" as |field|>
+ <field.Control />
+ </form.Field>
+ </Form>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/collection.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/collection.gjs
new file mode 100644
index 00000000000..c7779d51401
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/collection.gjs
@@ -0,0 +1,31 @@
+import { array, fn, hash } from "@ember/helper";
+import Form from "discourse/components/form";
+
+export default <template>
+ <Form
+ @data={{hash foo=(array (hash bar=1 baz=2) (hash bar=3 baz=4))}}
+ as |form|
+ >
+ <form.Button @action={{fn form.addItemToCollection "foo"}} @icon="plus" />
+
+ <form.Collection @name="foo" as |collection index|>
+ <form.Row as |row|>
+ <row.Col @size={{6}}>
+ <collection.Field @title="Bar" @name="bar" @type="input" as |field|>
+ <field.Control />
+ </collection.Field>
+ </row.Col>
+
+ <row.Col @size={{4}}>
+ <collection.Field @title="Baz" @name="baz" @type="input" as |field|>
+ <field.Control />
+ </collection.Field>
+ </row.Col>
+
+ <row.Col @size={{2}}>
+ <form.Button @action={{fn collection.remove index}} @icon="minus" />
+ </row.Col>
+ </form.Row>
+ </form.Collection>
+ </Form>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/color-named.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/color-named.gjs
new file mode 100644
index 00000000000..b34df49f9ea
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/color-named.gjs
@@ -0,0 +1,9 @@
+import Form from "discourse/components/form";
+
+export default <template>
+ <Form as |form|>
+ <form.Field @title="Color" @name="color" @type="color" as |field|>
+ <field.Control @allowNamedColors={{true}} placeholder="red, FF0000" />
+ </form.Field>
+ </Form>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/color-prefix-hex.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/color-prefix-hex.gjs
new file mode 100644
index 00000000000..0491e4365eb
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/color-prefix-hex.gjs
@@ -0,0 +1,9 @@
+import Form from "discourse/components/form";
+
+export default <template>
+ <Form as |form|>
+ <form.Field @title="Color" @name="color" @type="color" as |field|>
+ <field.Control @prefixHex={{true}} placeholder="RRGGBB" />
+ </form.Field>
+ </Form>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/color-swatches.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/color-swatches.gjs
new file mode 100644
index 00000000000..7062eede4cb
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/color-swatches.gjs
@@ -0,0 +1,14 @@
+import { array } from "@ember/helper";
+import Form from "discourse/components/form";
+
+export default <template>
+ <Form as |form|>
+ <form.Field @title="Color" @name="color" @type="color" as |field|>
+ <field.Control
+ @colors={{array "FF0000" "00FF00" "0000FF" "FFFF00" "FF00FF" "00FFFF"}}
+ @usedColors={{array "00FF00"}}
+ placeholder="RRGGBB"
+ />
+ </form.Field>
+ </Form>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/color.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/color.gjs
new file mode 100644
index 00000000000..56065a370e1
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/color.gjs
@@ -0,0 +1,9 @@
+import Form from "discourse/components/form";
+
+export default <template>
+ <Form as |form|>
+ <form.Field @title="Color" @name="color" @type="color" as |field|>
+ <field.Control placeholder="RRGGBB" />
+ </form.Field>
+ </Form>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/composer.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/composer.gjs
new file mode 100644
index 00000000000..ddc94d2a71e
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/composer.gjs
@@ -0,0 +1,9 @@
+import Form from "discourse/components/form";
+
+export default <template>
+ <Form as |form|>
+ <form.Field @title="Query" @name="query" @type="composer" as |field|>
+ <field.Control />
+ </form.Field>
+ </Form>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/icon.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/icon.gjs
new file mode 100644
index 00000000000..15435a6ea20
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/icon.gjs
@@ -0,0 +1,9 @@
+import Form from "discourse/components/form";
+
+export default <template>
+ <Form as |form|>
+ <form.Field @title="Icon" @name="icon" @type="icon" as |field|>
+ <field.Control />
+ </form.Field>
+ </Form>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/image.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/image.gjs
new file mode 100644
index 00000000000..642280a85a7
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/image.gjs
@@ -0,0 +1,9 @@
+import Form from "discourse/components/form";
+
+export default <template>
+ <Form as |form|>
+ <form.Field @title="Image" @name="image" @type="image" as |field|>
+ <field.Control @type="avatar" />
+ </form.Field>
+ </Form>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/input-group.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/input-group.gjs
new file mode 100644
index 00000000000..8da1b21afc0
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/input-group.gjs
@@ -0,0 +1,19 @@
+import Form from "discourse/components/form";
+
+export default <template>
+ <Form as |form|>
+ <form.InputGroup as |inputGroup|>
+ <inputGroup.Field
+ @title="Username"
+ @name="username"
+ @type="input"
+ as |field|
+ >
+ <field.Control />
+ </inputGroup.Field>
+ <inputGroup.Field @title="Email" @name="email" @type="input" as |field|>
+ <field.Control />
+ </inputGroup.Field>
+ </form.InputGroup>
+ </Form>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/input.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/input.gjs
new file mode 100644
index 00000000000..507e3c5c5e5
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/input.gjs
@@ -0,0 +1,30 @@
+import Form from "discourse/components/form";
+
+export default <template>
+ <Form as |form|>
+ <form.Field @title="Username" @name="username" @type="input" as |field|>
+ <field.Control placeholder="Username" />
+ </form.Field>
+ <form.Field @title="Age" @name="age" @type="input-number" as |field|>
+ <field.Control placeholder="Age" @format="small" />
+ </form.Field>
+ <form.Field @title="Website" @name="website" @type="input" as |field|>
+ <field.Control @before="https://" @after=".com" @format="large" />
+ </form.Field>
+ <form.Field @title="After" @name="after" @type="input" as |field|>
+ <field.Control @after=".com" />
+ </form.Field>
+ <form.Field @title="Before" @name="before" @type="input" as |field|>
+ <field.Control @before="https://" />
+ </form.Field>
+ <form.Field
+ @title="Secret"
+ @name="secret"
+ @description="An important password"
+ @type="password"
+ as |field|
+ >
+ <field.Control />
+ </form.Field>
+ </Form>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/menu.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/menu.gjs
new file mode 100644
index 00000000000..f44eb21ecdd
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/menu.gjs
@@ -0,0 +1,13 @@
+import Form from "discourse/components/form";
+
+export default <template>
+ <Form as |form data|>
+ <form.Field @title="Enabled" @name="enabled" @type="menu" as |field|>
+ <field.Control @selection={{data.enabled}} as |menu|>
+ <menu.Item @value="true">Yes</menu.Item>
+ <menu.Divider />
+ <menu.Item @value="false">No</menu.Item>
+ </field.Control>
+ </form.Field>
+ </Form>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/multiline.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/multiline.gjs
new file mode 100644
index 00000000000..cc5c11223a7
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/multiline.gjs
@@ -0,0 +1,30 @@
+import Form from "discourse/components/form";
+
+export default <template>
+ <Form as |form|>
+ <form.Row as |row|>
+ <row.Col @size={{6}}>
+ <form.Field
+ @title="Username"
+ @name="username"
+ @validation="required"
+ @type="input"
+ as |field|
+ >
+ <field.Control />
+ </form.Field>
+ </row.Col>
+ <row.Col @size={{6}}>
+ <form.Field @title="Email" @name="email" @type="input" as |field|>
+ <field.Control />
+ </form.Field>
+ </row.Col>
+
+ <row.Col @size={{12}}>
+ <form.Field @title="Address" @name="address" @type="input" as |field|>
+ <field.Control />
+ </form.Field>
+ </row.Col>
+ </form.Row>
+ </Form>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/question.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/question.gjs
new file mode 100644
index 00000000000..cad88b2402d
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/question.gjs
@@ -0,0 +1,9 @@
+import Form from "discourse/components/form";
+
+export default <template>
+ <Form as |form|>
+ <form.Field @title="Enabled" @name="enabled" @type="question" as |field|>
+ <field.Control />
+ </form.Field>
+ </Form>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/radio-group.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/radio-group.gjs
new file mode 100644
index 00000000000..1c85ed788ac
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/radio-group.gjs
@@ -0,0 +1,23 @@
+import Form from "discourse/components/form";
+
+export default <template>
+ <Form as |form|>
+ <form.Field
+ @title="Enabled"
+ @name="enabled"
+ @format="full"
+ @type="radio-group"
+ as |field|
+ >
+ <field.Control as |radioGroup|>
+ <radioGroup.Radio @value="true">Yes</radioGroup.Radio>
+ <radioGroup.Radio @value="false" as |radio|>
+ <radio.Title>No</radio.Title>
+ <radio.Description>
+ Choosing no, will make you ineligible for the contest.
+ </radio.Description>
+ </radioGroup.Radio>
+ </field.Control>
+ </form.Field>
+ </Form>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/row-col.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/row-col.gjs
new file mode 100644
index 00000000000..d831be1824c
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/row-col.gjs
@@ -0,0 +1,27 @@
+import Form from "discourse/components/form";
+
+export default <template>
+ <Form as |form|>
+ <form.Row as |row|>
+ <row.Col @size={{6}}>
+ <form.Field
+ @title="Username"
+ @name="username"
+ @validation="required"
+ @type="input"
+ as |field|
+ >
+ <field.Control />
+ </form.Field>
+ </row.Col>
+ <row.Col @size={{4}}>
+ <form.Field @title="Email" @name="email" @type="input" as |field|>
+ <field.Control />
+ </form.Field>
+ </row.Col>
+ <row.Col @size={{2}}>
+ <form.Submit />
+ </row.Col>
+ </form.Row>
+ </Form>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/section.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/section.gjs
new file mode 100644
index 00000000000..f1eadcf6cae
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/section.gjs
@@ -0,0 +1,9 @@
+import Form from "discourse/components/form";
+
+export default <template>
+ <Form as |form|>
+ <form.Section @title="Section title">
+ Content
+ </form.Section>
+ </Form>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/select.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/select.gjs
new file mode 100644
index 00000000000..acf11651c0b
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/select.gjs
@@ -0,0 +1,12 @@
+import Form from "discourse/components/form";
+
+export default <template>
+ <Form as |form|>
+ <form.Field @title="Enabled" @name="enabled" @type="select" as |field|>
+ <field.Control as |select|>
+ <select.Option @value="true">Yes</select.Option>
+ <select.Option @value="false">No</select.Option>
+ </field.Control>
+ </form.Field>
+ </Form>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/tag-chooser.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/tag-chooser.gjs
new file mode 100644
index 00000000000..c7e3f4ab5a8
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/tag-chooser.gjs
@@ -0,0 +1,9 @@
+import Form from "discourse/components/form";
+
+export default <template>
+ <Form as |form|>
+ <form.Field @title="Tags" @name="tags" @type="tag-chooser" as |field|>
+ <field.Control />
+ </form.Field>
+ </Form>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/textarea.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/textarea.gjs
new file mode 100644
index 00000000000..8587863f1de
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/textarea.gjs
@@ -0,0 +1,9 @@
+import Form from "discourse/components/form";
+
+export default <template>
+ <Form as |form|>
+ <form.Field @title="Query" @name="query" @type="textarea" as |field|>
+ <field.Control />
+ </form.Field>
+ </Form>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/toggle.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/toggle.gjs
new file mode 100644
index 00000000000..7011c9ae3df
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/toggle.gjs
@@ -0,0 +1,9 @@
+import Form from "discourse/components/form";
+
+export default <template>
+ <Form as |form|>
+ <form.Field @title="Enabled" @name="enabled" @type="toggle" as |field|>
+ <field.Control />
+ </form.Field>
+ </Form>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/validation.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/validation.gjs
new file mode 100644
index 00000000000..6c89f72f525
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/forms/validation.gjs
@@ -0,0 +1,28 @@
+import Form from "discourse/components/form";
+
+export default <template>
+ <Form @validateOn="change" as |form|>
+ <form.Field
+ @title="Username"
+ @name="username"
+ @validation="required"
+ @type="input"
+ as |field|
+ >
+ <field.Control />
+ </form.Field>
+
+ <form.Field
+ @name="accept_terms"
+ @title="Accept terms"
+ @validation="required"
+ @format="large"
+ @type="checkbox"
+ as |field|
+ >
+ <field.Control />
+ </form.Field>
+
+ <form.Submit />
+ </Form>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/otp/callbacks.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/otp/callbacks.gjs
new file mode 100644
index 00000000000..46092a5865e
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/otp/callbacks.gjs
@@ -0,0 +1,34 @@
+import Component from "@glimmer/component";
+import { tracked } from "@glimmer/tracking";
+import { action } from "@ember/object";
+import DOtp from "discourse/ui-kit/d-otp";
+
+export default class OtpCallbacksExample extends Component {
+ @tracked changedOutput;
+ @tracked filledOutput;
+
+ @action
+ changed(otp) {
+ this.filledOutput = null;
+ this.changedOutput = otp.length ? `changed: ${otp}` : null;
+ }
+
+ @action
+ filled(otp) {
+ this.filledOutput = `filled: ${otp}`;
+ }
+
+ <template>
+ <DOtp @onFill={{this.filled}} @onChange={{this.changed}} />
+
+ {{#if this.changedOutput}}
+ <output>
+ <p>{{this.changedOutput}}</p>
+
+ {{#if this.filledOutput}}
+ <p>{{this.filledOutput}}</p>
+ {{/if}}
+ </output>
+ {{/if}}
+ </template>
+}
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/otp/slots.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/otp/slots.gjs
new file mode 100644
index 00000000000..e83e27f24fc
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/otp/slots.gjs
@@ -0,0 +1,3 @@
+import DOtp from "discourse/ui-kit/d-otp";
+
+export default <template><DOtp @slots={{4}} /></template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/spinners/regular.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/spinners/regular.gjs
new file mode 100644
index 00000000000..09f7ce7179b
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/spinners/regular.gjs
@@ -0,0 +1,3 @@
+export default <template>
+ <div class="spinner"></div>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/spinner-small.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/spinners/small.gjs
similarity index 100%
rename from plugins/styleguide/assets/javascripts/discourse/components/examples/spinner-small.gjs
rename to plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/spinners/small.gjs
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/topic-link-status/no-status.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/topic-link-status/no-status.gjs
new file mode 100644
index 00000000000..1dc81f7bdbf
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/topic-link-status/no-status.gjs
@@ -0,0 +1,3 @@
+import dTopicLink from "discourse/ui-kit/helpers/d-topic-link";
+
+export default <template>{{dTopicLink @topic}}</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/topic-link-status/with-status.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/topic-link-status/with-status.gjs
new file mode 100644
index 00000000000..d040bf1b132
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/atoms/topic-link-status/with-status.gjs
@@ -0,0 +1,7 @@
+import TopicStatus from "discourse/components/topic-status";
+import dTopicLink from "discourse/ui-kit/helpers/d-topic-link";
+
+export default <template>
+ <TopicStatus @topic={{@topic}} />
+ {{dTopicLink @topic}}
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/char-counter.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/char-counter.gjs
deleted file mode 100644
index 9b4734b9d00..00000000000
--- a/plugins/styleguide/assets/javascripts/discourse/components/examples/char-counter.gjs
+++ /dev/null
@@ -1,13 +0,0 @@
-import { fn } from "@ember/helper";
-import { on } from "@ember/modifier";
-import withEventValue from "discourse/helpers/with-event-value";
-import DCharCounter from "discourse/ui-kit/d-char-counter";
-
-export default <template>
- <DCharCounter @max="50" @value={{@dummy.charCounterContent}}>
- <textarea
- {{on "input" (withEventValue (fn (mut @dummy.charCounterContent)))}}
- class="styleguide--char-counter"
- ></textarea>
- </DCharCounter>
-</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/bread-crumbs.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/bread-crumbs.gjs
new file mode 100644
index 00000000000..2807c68810d
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/bread-crumbs.gjs
@@ -0,0 +1,5 @@
+import BreadCrumbs from "discourse/components/bread-crumbs";
+
+export default <template>
+ <BreadCrumbs @categories={{@categories}} @showTags={{false}} />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/category-badge.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/category-badge.gjs
new file mode 100644
index 00000000000..b2b9cdb5c8e
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/category-badge.gjs
@@ -0,0 +1,7 @@
+import dCategoryBadge from "discourse/ui-kit/helpers/d-category-badge";
+
+export default <template>
+ {{#each @categories key="id" as |category|}}
+ {{dCategoryBadge category categoryStyle="bullet"}}
+ {{/each}}
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/char-counter.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/char-counter.gjs
new file mode 100644
index 00000000000..ed50647f2ec
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/char-counter.gjs
@@ -0,0 +1,24 @@
+import Component from "@glimmer/component";
+import { tracked } from "@glimmer/tracking";
+import { on } from "@ember/modifier";
+import { action } from "@ember/object";
+import withEventValue from "discourse/helpers/with-event-value";
+import DCharCounter from "discourse/ui-kit/d-char-counter";
+
+export default class CharCounterExample extends Component {
+ @tracked content = "";
+
+ @action
+ updateContent(value) {
+ this.content = value;
+ }
+
+ <template>
+ <DCharCounter @max="50" @value={{this.content}}>
+ <textarea
+ {{on "input" (withEventValue this.updateContent)}}
+ class="styleguide--char-counter"
+ ></textarea>
+ </DCharCounter>
+ </template>
+}
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/empty-state.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/empty-state.gjs
new file mode 100644
index 00000000000..5d1d673486a
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/empty-state.gjs
@@ -0,0 +1,8 @@
+import DEmptyState from "discourse/ui-kit/d-empty-state";
+
+export default <template>
+ <DEmptyState
+ @title="Donec viverra lacus id sapien aliquam, tempus tincidunt urna porttitor."
+ @body="Lorem ipsum dolor sit amet."
+ />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/group-nav-pills.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/group-nav-pills.gjs
new file mode 100644
index 00000000000..3954e9b2e96
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/group-nav-pills.gjs
@@ -0,0 +1,20 @@
+import MobileNav from "discourse/components/mobile-nav";
+import GroupDropdown from "discourse/select-kit/components/group-dropdown";
+
+const GROUPS = ["staff", "lounge", "admin"];
+
+export default <template>
+ <MobileNav @desktopClass="nav nav-pills" class="group-nav">
+ <li class="group-dropdown">
+ <GroupDropdown @groups={{GROUPS}} @value="staff" />
+ </li>
+
+ {{#each @navItems key="name" as |navItem|}}
+ <li>
+ <a href={{navItem.href}} class={{if navItem.styleGuideActive "active"}}>
+ {{navItem.displayName}}
+ </a>
+ </li>
+ {{/each}}
+ </MobileNav>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/multi-select.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/multi-select.gjs
new file mode 100644
index 00000000000..2dd84cfa289
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/multi-select.gjs
@@ -0,0 +1,39 @@
+import Component from "@glimmer/component";
+import { tracked } from "@glimmer/tracking";
+import { action } from "@ember/object";
+import DMultiSelect from "discourse/ui-kit/d-multi-select";
+
+const ITEMS = [
+ { id: 1, name: "foo" },
+ { id: 2, name: "bar" },
+ { id: 3, name: "baz" },
+];
+
+export default class MultiSelectExample extends Component {
+ @tracked selection = [ITEMS[0]];
+
+ @action
+ async load(filter) {
+ await new Promise((resolve) => setTimeout(resolve, 500));
+
+ return ITEMS.filter((item) =>
+ item.name.toLowerCase().includes(filter.toLowerCase())
+ );
+ }
+
+ @action
+ onChange(selection) {
+ this.selection = selection;
+ }
+
+ <template>
+ <DMultiSelect
+ @loadFn={{this.load}}
+ @onChange={{this.onChange}}
+ @selection={{this.selection}}
+ >
+ <:result as |result|>{{result.name}}</:result>
+ <:selection as |result|>{{result.name}}</:selection>
+ </DMultiSelect>
+ </template>
+}
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/nav-stacked.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/nav-stacked.gjs
new file mode 100644
index 00000000000..3b6ce363b2a
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/nav-stacked.gjs
@@ -0,0 +1,16 @@
+import MobileNav from "discourse/components/mobile-nav";
+
+export default <template>
+ <MobileNav
+ @desktopClass="preferences-list action-list nav-stacked"
+ class="preferences-nav"
+ >
+ {{#each @navItems key="name" as |navItem|}}
+ <li>
+ <a href={{navItem.href}} class={{if navItem.styleGuideActive "active"}}>
+ {{navItem.displayName}}
+ </a>
+ </li>
+ {{/each}}
+ </MobileNav>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/navigation-bar.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/navigation-bar.gjs
new file mode 100644
index 00000000000..10b1d41d615
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/navigation-bar.gjs
@@ -0,0 +1,5 @@
+import NavigationBar from "discourse/components/navigation-bar";
+
+export default <template>
+ <NavigationBar @navItems={{@navItems}} @filterMode="latest" />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/post-menu.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/post-menu.gjs
new file mode 100644
index 00000000000..f235d867fca
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/post-menu.gjs
@@ -0,0 +1,12 @@
+import PostMenu from "discourse/components/post/menu";
+
+export default <template>
+ <PostMenu
+ @post={{@post}}
+ @canCreatePost={{true}}
+ @showFlags={{true}}
+ @showLogin={{true}}
+ @showReadIndicator={{true}}
+ @toggleLike={{true}}
+ />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/segmented-control.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/segmented-control.gjs
new file mode 100644
index 00000000000..f0a851b40f1
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/segmented-control.gjs
@@ -0,0 +1,30 @@
+import Component from "@glimmer/component";
+import { tracked } from "@glimmer/tracking";
+import { action } from "@ember/object";
+import DSegmentedControl from "discourse/components/d-segmented-control";
+
+const ITEMS = [
+ { value: "day", label: "Day" },
+ { value: "week", label: "Week" },
+ { value: "month", label: "Month" },
+ { value: "year", label: "Year" },
+ { value: "all", label: "All" },
+];
+
+export default class SegmentedControlExample extends Component {
+ @tracked selected = "week";
+
+ @action
+ onSelect(value) {
+ this.selected = value;
+ }
+
+ <template>
+ <DSegmentedControl
+ @name="time-period"
+ @items={{ITEMS}}
+ @value={{this.selected}}
+ @onSelect={{this.onSelect}}
+ />
+ </template>
+}
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/signup-cta.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/signup-cta.gjs
new file mode 100644
index 00000000000..fd129ff4c73
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/signup-cta.gjs
@@ -0,0 +1,3 @@
+import SignupCta from "discourse/components/signup-cta";
+
+export default <template><SignupCta /></template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/topic-list-item.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/topic-list-item.gjs
new file mode 100644
index 00000000000..aa9d7e51fe3
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/topic-list-item.gjs
@@ -0,0 +1,70 @@
+import Component from "@glimmer/component";
+import HeaderActivityCell from "discourse/components/topic-list/header/activity-cell";
+import HeaderLikesCell from "discourse/components/topic-list/header/likes-cell";
+import HeaderPostersCell from "discourse/components/topic-list/header/posters-cell";
+import HeaderRepliesCell from "discourse/components/topic-list/header/replies-cell";
+import HeaderTopicCell from "discourse/components/topic-list/header/topic-cell";
+import HeaderViewsCell from "discourse/components/topic-list/header/views-cell";
+import Item from "discourse/components/topic-list/item";
+import ItemActivityCell from "discourse/components/topic-list/item/activity-cell";
+import ItemLikesCell from "discourse/components/topic-list/item/likes-cell";
+import ItemPostersCell from "discourse/components/topic-list/item/posters-cell";
+import ItemRepliesCell from "discourse/components/topic-list/item/replies-cell";
+import ItemTopicCell from "discourse/components/topic-list/item/topic-cell";
+import ItemViewsCell from "discourse/components/topic-list/item/views-cell";
+import DAG from "discourse/lib/dag";
+import { applyMutableValueTransformer } from "discourse/lib/transformer";
+
+export default class TopicListItemExample extends Component {
+ // A parent TopicList normally builds this and hands it down; an Item on its
+ // own has to resolve the column set itself.
+ get columns() {
+ const defaultColumns = new DAG({
+ // Allow customizations to replace just a header cell or just an item cell
+ onReplaceItem(_, newValue, oldValue) {
+ newValue.header ??= oldValue.header;
+ newValue.item ??= oldValue.item;
+ },
+ });
+
+ defaultColumns.add("topic", {
+ header: HeaderTopicCell,
+ item: ItemTopicCell,
+ });
+
+ if (this.args.showPosters) {
+ defaultColumns.add("posters", {
+ header: HeaderPostersCell,
+ item: ItemPostersCell,
+ });
+ }
+
+ defaultColumns.add("replies", {
+ header: HeaderRepliesCell,
+ item: ItemRepliesCell,
+ });
+
+ defaultColumns.add("likes", {
+ header: HeaderLikesCell,
+ item: ItemLikesCell,
+ });
+
+ defaultColumns.add("views", {
+ header: HeaderViewsCell,
+ item: ItemViewsCell,
+ });
+
+ defaultColumns.add("activity", {
+ header: HeaderActivityCell,
+ item: ItemActivityCell,
+ });
+
+ return applyMutableValueTransformer(
+ "topic-list-columns",
+ defaultColumns,
+ {}
+ ).resolve();
+ }
+
+ <template><Item @topic={{@topic}} @columns={{this.columns}} /></template>
+}
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/topic-notifications-button.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/topic-notifications-button.gjs
new file mode 100644
index 00000000000..2d7ed1693bc
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/topic-notifications-button.gjs
@@ -0,0 +1,5 @@
+import TopicNotificationsButton from "discourse/select-kit/components/topic-notifications-button";
+
+export default <template>
+ <TopicNotificationsButton @topic={{@topic}} @expanded={{@expanded}} />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/topic-timer-info.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/topic-timer-info.gjs
new file mode 100644
index 00000000000..7fd98cf62f3
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/topic-timer-info.gjs
@@ -0,0 +1,7 @@
+import TopicTimerInfo from "discourse/components/topic-timer-info";
+
+const EXECUTE_AT = moment().add(2, "days");
+
+export default <template>
+ <TopicTimerInfo @statusType="reminder" @executeAt={{EXECUTE_AT}} />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/user-nav-pills.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/user-nav-pills.gjs
new file mode 100644
index 00000000000..90f063b75a4
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/user-nav-pills.gjs
@@ -0,0 +1,13 @@
+import MobileNav from "discourse/components/mobile-nav";
+
+export default <template>
+ <MobileNav @desktopClass="nav nav-pills user-nav" class="main-nav">
+ {{#each @navItems key="name" as |navItem|}}
+ <li>
+ <a href={{navItem.href}} class={{if navItem.styleGuideActive "active"}}>
+ {{navItem.displayName}}
+ </a>
+ </li>
+ {{/each}}
+ </MobileNav>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/user-nav-stacked.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/user-nav-stacked.gjs
new file mode 100644
index 00000000000..19a50d9a71f
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/molecules/user-nav-stacked.gjs
@@ -0,0 +1,21 @@
+import MobileNav from "discourse/components/mobile-nav";
+
+export default <template>
+ <section class="user-navigation">
+ <MobileNav
+ @desktopClass="preferences-list action-list nav-stacked"
+ class="preferences-nav"
+ >
+ {{#each @navItems key="name" as |navItem|}}
+ <li>
+ <a
+ href={{navItem.href}}
+ class={{if navItem.styleGuideActive "active"}}
+ >
+ {{navItem.displayName}}
+ </a>
+ </li>
+ {{/each}}
+ </MobileNav>
+ </section>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/basic-topic-list.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/basic-topic-list.gjs
new file mode 100644
index 00000000000..dade9e13868
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/basic-topic-list.gjs
@@ -0,0 +1,3 @@
+import BasicTopicList from "discourse/components/basic-topic-list";
+
+export default <template><BasicTopicList @topics={{@topics}} /></template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/categories-only.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/categories-only.gjs
new file mode 100644
index 00000000000..80ccc84f2c5
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/categories-only.gjs
@@ -0,0 +1,9 @@
+import Component from "@glimmer/component";
+import { service } from "@ember/service";
+import CategoriesOnly from "discourse/components/categories-only";
+
+export default class CategoriesOnlyExample extends Component {
+ @service site;
+
+ <template><CategoriesOnly @categories={{this.site.categories}} /></template>
+}
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/navigation.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/navigation.gjs
new file mode 100644
index 00000000000..d7cbcd6ee56
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/navigation.gjs
@@ -0,0 +1,20 @@
+import BreadCrumbs from "discourse/components/bread-crumbs";
+import CreateTopicButton from "discourse/components/create-topic-button";
+import NavigationBar from "discourse/components/navigation-bar";
+import CategoriesAdminDropdown from "discourse/select-kit/components/categories-admin-dropdown";
+
+export default <template>
+ <div class="list-controls">
+ <div class="container">
+ <section class="navigation-container">
+ <BreadCrumbs @categories={{@categories}} />
+ <NavigationBar @navItems={{@navItems}} @filterMode="latest" />
+
+ <div class="navigation-controls">
+ <CategoriesAdminDropdown />
+ <CreateTopicButton @canCreateTopic={{true}} />
+ </div>
+ </section>
+ </div>
+ </div>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/post-list-empty.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/post-list-empty.gjs
new file mode 100644
index 00000000000..d6ff4870b94
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/post-list-empty.gjs
@@ -0,0 +1,5 @@
+import PostList from "discourse/components/post-list";
+
+export default <template>
+ <PostList @posts="" @additionalItemClasses="styleguide-post-list-item" />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/post-list.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/post-list.gjs
new file mode 100644
index 00000000000..ac23f39d038
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/post-list.gjs
@@ -0,0 +1,8 @@
+import PostList from "discourse/components/post-list";
+
+export default <template>
+ <PostList
+ @posts={{@posts}}
+ @additionalItemClasses="styleguide-post-list-item"
+ />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/post.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/post.gjs
new file mode 100644
index 00000000000..1cf6b4ff796
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/post.gjs
@@ -0,0 +1,5 @@
+import Post from "discourse/components/post";
+
+export default <template>
+ <Post @post={{@post}} @canCreatePost={{true}} />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/site-header-in-topic.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/site-header-in-topic.gjs
new file mode 100644
index 00000000000..4046f11be9e
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/site-header-in-topic.gjs
@@ -0,0 +1,11 @@
+import Header from "discourse/components/header";
+
+export default <template>
+ <div inert class="d-header-wrap">
+ <Header
+ @sidebarEnabled={{@sidebarEnabled}}
+ @topicInfo={{@topic}}
+ @topicInfoVisible={{true}}
+ />
+ </div>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/site-header.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/site-header.gjs
new file mode 100644
index 00000000000..a6c42b33380
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/site-header.gjs
@@ -0,0 +1,7 @@
+import Header from "discourse/components/header";
+
+export default <template>
+ <div inert class="d-header-wrap">
+ <Header @sidebarEnabled={{@sidebarEnabled}} />
+ </div>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/topic-footer-buttons-anonymous.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/topic-footer-buttons-anonymous.gjs
new file mode 100644
index 00000000000..00b671eff8e
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/topic-footer-buttons-anonymous.gjs
@@ -0,0 +1,11 @@
+import DButton from "discourse/ui-kit/d-button";
+
+export default <template>
+ <div id="topic-footer-buttons">
+ <DButton
+ @icon="reply"
+ @label="topic.reply.title"
+ class="btn-primary pull-right"
+ />
+ </div>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/topic-footer-buttons.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/topic-footer-buttons.gjs
new file mode 100644
index 00000000000..4af16f4e44a
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/topic-footer-buttons.gjs
@@ -0,0 +1,3 @@
+import TopicFooterButtons from "discourse/components/topic-footer-buttons";
+
+export default <template><TopicFooterButtons @topic={{@topic}} /></template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/topic-list-without-posters.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/topic-list-without-posters.gjs
new file mode 100644
index 00000000000..d42f27e9c0c
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/topic-list-without-posters.gjs
@@ -0,0 +1,5 @@
+import TopicList from "discourse/components/topic-list/list";
+
+export default <template>
+ <TopicList @topics={{@topics}} @showPosters={{false}} />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/topic-list.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/topic-list.gjs
new file mode 100644
index 00000000000..3593cb9d69f
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/topic-list.gjs
@@ -0,0 +1,5 @@
+import TopicList from "discourse/components/topic-list/list";
+
+export default <template>
+ <TopicList @topics={{@topics}} @showPosters={{true}} />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/topic-map.gjs b/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/topic-map.gjs
new file mode 100644
index 00000000000..62f686d8c5f
--- /dev/null
+++ b/plugins/styleguide/assets/javascripts/discourse/components/examples/organisms/topic-map.gjs
@@ -0,0 +1,5 @@
+import TopicMap from "discourse/components/topic-map";
+
+export default <template>
+ <TopicMap @model={{@post}} @topicDetails={{@post.topic.details}} />
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/02-buttons.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/02-buttons.gjs
index c5069a99726..c85dff0b9a2 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/02-buttons.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/02-buttons.gjs
@@ -1,495 +1,132 @@
-import Component from "@glimmer/component";
-import { fn } from "@ember/helper";
-import { on } from "@ember/modifier";
-import { not } from "discourse/truth-helpers";
-import DButton from "discourse/ui-kit/d-button";
-import DToggleSwitch from "discourse/ui-kit/d-toggle-switch";
-import dConcatClass from "discourse/ui-kit/helpers/d-concat-class";
import StyleguideExample from "discourse/plugins/styleguide/discourse/components/styleguide-example";
-
-export default class Buttons extends Component {
- get btnIconSizesCode() {
- return `
-import DButton from "discourse/components/d-button";
-
-// Size classes: btn-large, btn-default, btn-small
-<template>
- <DButton @icon="xmark" @disabled={{false}} class="btn-large" />
- <DButton @icon="xmark" @disabled={{false}} class="btn-default" />
- <DButton @icon="xmark" @disabled={{false}} class="btn-small" />
-</template>
- `;
- }
-
- get btnIconStatesCode() {
- return `
-import DButton from "discourse/components/d-button";
-
-// Available states: normal, hover, disabled
-<template>
- <DButton @icon="xmark" @disabled={{false}} class="btn-default" />
- <DButton @icon="xmark" @disabled={{false}} class="btn-default btn-hover" />
- <DButton @icon="xmark" @disabled={{true}} class="btn-default" />
-</template>
- `;
- }
-
- get btnTextSizesCode() {
- return `
-import DButton from "discourse/components/d-button";
-import concatClass from "discourse/helpers/concat-class";
-
-<template>
- {{#each @dummy.buttonSizes as |bs|}}
- <DButton
- @translatedLabel={{bs.text}}
- @disabled={{bs.disabled}}
- class={{concatClass "btn-default" bs.class}}
- />
- {{/each}}
-</template>
- `;
- }
-
- get btnTextStatesCode() {
- return `
-import DButton from "discourse/components/d-button";
-import concatClass from "discourse/helpers/concat-class";
-
-<template>
- {{#each @dummy.buttonStates as |bs|}}
- <DButton
- @translatedLabel={{bs.text}}
- @disabled={{bs.disabled}}
- class={{concatClass "btn-default" bs.class}}
- />
- {{/each}}
-</template>
- `;
- }
-
- get btnDefaultIconTextSizesCode() {
- return `
-import DButton from "discourse/components/d-button";
-import concatClass from "discourse/helpers/concat-class";
-
-<template>
- {{#each @dummy.buttonSizes as |bs|}}
- <DButton
- @icon="plus"
- @translatedLabel={{bs.text}}
- @disabled={{bs.disabled}}
- class={{concatClass "btn-default" bs.class}}
- />
- {{/each}}
-</template>
- `;
- }
-
- get btnDefaultIconTextStatesCode() {
- return `
-import DButton from "discourse/components/d-button";
-import concatClass from "discourse/helpers/concat-class";
-
-<template>
- {{#each @dummy.buttonStates as |bs|}}
- <DButton
- @icon="plus"
- @translatedLabel={{bs.text}}
- @disabled={{bs.disabled}}
- class={{concatClass "btn-default" bs.class}}
- />
- {{/each}}
-</template>
- `;
- }
-
- get btnPrimaryIconTextSizesCode() {
- return `
-import DButton from "discourse/components/d-button";
-import concatClass from "discourse/helpers/concat-class";
-
-<template>
- {{#each @dummy.buttonSizes as |bs|}}
- <DButton
- @icon="plus"
- @translatedLabel={{bs.text}}
- @disabled={{bs.disabled}}
- class={{concatClass "btn-primary" bs.class}}
- />
- {{/each}}
-</template>
- `;
- }
-
- get btnPrimaryIconTextStatesCode() {
- return `
-import DButton from "discourse/components/d-button";
-import concatClass from "discourse/helpers/concat-class";
-
-<template>
- {{#each @dummy.buttonStates as |bs|}}
- <DButton
- @icon="plus"
- @translatedLabel={{bs.text}}
- @disabled={{bs.disabled}}
- class={{concatClass "btn-primary" bs.class}}
- />
- {{/each}}
-</template>
- `;
- }
-
- get btnDangerIconTextSizesCode() {
- return `
-import DButton from "discourse/components/d-button";
-import concatClass from "discourse/helpers/concat-class";
-
-<template>
- {{#each @dummy.buttonSizes as |bs|}}
- <DButton
- @icon="trash-can"
- @translatedLabel={{bs.text}}
- @disabled={{bs.disabled}}
- class={{concatClass "btn-danger" bs.class}}
- />
- {{/each}}
-</template>
- `;
- }
-
- get btnDangerIconTextStatesCode() {
- return `
-import DButton from "discourse/components/d-button";
-import concatClass from "discourse/helpers/concat-class";
-
-<template>
- {{#each @dummy.buttonStates as |bs|}}
- <DButton
- @icon="trash-can"
- @translatedLabel={{bs.text}}
- @disabled={{bs.disabled}}
- class={{concatClass "btn-danger" bs.class}}
- />
- {{/each}}
-</template>
- `;
- }
-
- get btnFlatSizesCode() {
- return `
-import DButton from "discourse/components/d-button";
-import concatClass from "discourse/helpers/concat-class";
-
-<template>
- {{#each @dummy.buttonSizes as |bs|}}
- <DButton
- @icon="trash-can"
- @disabled={{bs.disabled}}
- @translatedTitle={{bs.title}}
- class={{concatClass "btn-flat" bs.class}}
- />
- {{/each}}
-</template>
- `;
- }
-
- get btnFlatStatesCode() {
- return `
-import DButton from "discourse/components/d-button";
-import concatClass from "discourse/helpers/concat-class";
-
-<template>
- {{#each @dummy.buttonStates as |bs|}}
- <DButton
- @icon="trash-can"
- @disabled={{bs.disabled}}
- @translatedLabel={{bs.text}}
- class={{concatClass "btn-flat" bs.class}}
- />
- {{/each}}
-</template>
- `;
- }
-
- get btnTransparentStatesCode() {
- return `
-import DButton from "discourse/components/d-button";
-import concatClass from "discourse/helpers/concat-class";
-
-<template>
- {{#each @dummy.buttonStates as |bs|}}
- <DButton
- @icon="trash-can"
- @disabled={{bs.disabled}}
- @translatedLabel={{bs.text}}
- class={{concatClass "btn-transparent" bs.class}}
- />
- {{/each}}
+import DangerSizesExample from "../../examples/atoms/buttons/danger-sizes";
+import dangerSizesSource from "../../examples/atoms/buttons/danger-sizes?source=file";
+import DangerStatesExample from "../../examples/atoms/buttons/danger-states";
+import dangerStatesSource from "../../examples/atoms/buttons/danger-states?source=file";
+import FlatSizesExample from "../../examples/atoms/buttons/flat-sizes";
+import flatSizesSource from "../../examples/atoms/buttons/flat-sizes?source=file";
+import FlatStatesExample from "../../examples/atoms/buttons/flat-states";
+import flatStatesSource from "../../examples/atoms/buttons/flat-states?source=file";
+import IconSizesExample from "../../examples/atoms/buttons/icon-sizes";
+import iconSizesSource from "../../examples/atoms/buttons/icon-sizes?source=file";
+import IconStatesExample from "../../examples/atoms/buttons/icon-states";
+import iconStatesSource from "../../examples/atoms/buttons/icon-states?source=file";
+import IconTextSizesExample from "../../examples/atoms/buttons/icon-text-sizes";
+import iconTextSizesSource from "../../examples/atoms/buttons/icon-text-sizes?source=file";
+import IconTextStatesExample from "../../examples/atoms/buttons/icon-text-states";
+import iconTextStatesSource from "../../examples/atoms/buttons/icon-text-states?source=file";
+import LinkExample from "../../examples/atoms/buttons/link";
+import linkSource from "../../examples/atoms/buttons/link?source=file";
+import PrimarySizesExample from "../../examples/atoms/buttons/primary-sizes";
+import primarySizesSource from "../../examples/atoms/buttons/primary-sizes?source=file";
+import PrimaryStatesExample from "../../examples/atoms/buttons/primary-states";
+import primaryStatesSource from "../../examples/atoms/buttons/primary-states?source=file";
+import TextSizesExample from "../../examples/atoms/buttons/text-sizes";
+import textSizesSource from "../../examples/atoms/buttons/text-sizes?source=file";
+import TextStatesExample from "../../examples/atoms/buttons/text-states";
+import textStatesSource from "../../examples/atoms/buttons/text-states?source=file";
+import ToggleSwitchExample from "../../examples/atoms/buttons/toggle-switch";
+import toggleSwitchSource from "../../examples/atoms/buttons/toggle-switch?source=file";
+import TransparentStatesExample from "../../examples/atoms/buttons/transparent-states";
+import transparentStatesSource from "../../examples/atoms/buttons/transparent-states?source=file";
+
+export default <template>
+ <StyleguideExample
+ @title="DButton - icon only - sizes (large, default, small)"
+ @code={{iconSizesSource}}
+ >
+ <IconSizesExample />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="DButton - icon only - states"
+ @code={{iconStatesSource}}
+ >
+ <IconStatesExample />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="DButton - text only - sizes (large, default, small)"
+ @code={{textSizesSource}}
+ >
+ <TextSizesExample />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="DButton - text only - states"
+ @code={{textStatesSource}}
+ >
+ <TextStatesExample />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="DButton - icon and text - sizes (large, default, small)"
+ @code={{iconTextSizesSource}}
+ >
+ <IconTextSizesExample />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="DButton - icon and text - states"
+ @code={{iconTextStatesSource}}
+ >
+ <IconTextStatesExample />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="DButton - icon and text - sizes"
+ @code={{primarySizesSource}}
+ >
+ <PrimarySizesExample />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="DButton - icon and text - btn-primary - states"
+ @code={{primaryStatesSource}}
+ >
+ <PrimaryStatesExample />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="DButton - icon and text - btn-danger - sizes"
+ @code={{dangerSizesSource}}
+ >
+ <DangerSizesExample />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="DButton - icon and text - btn-danger - states"
+ @code={{dangerStatesSource}}
+ >
+ <DangerStatesExample />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="DButton - btn-flat - icon only - sizes"
+ @code={{flatSizesSource}}
+ >
+ <FlatSizesExample />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="DButton - btn-flat - states"
+ @code={{flatStatesSource}}
+ >
+ <FlatStatesExample />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="DButton - btn-transparent - states"
+ @code={{transparentStatesSource}}
+ >
+ <TransparentStatesExample />
+ </StyleguideExample>
+
+ <StyleguideExample @title="DButton - link" @code={{linkSource}}>
+ <LinkExample />
+ </StyleguideExample>
+
+ <StyleguideExample @title="DToggleSwitch" @code={{toggleSwitchSource}}>
+ <ToggleSwitchExample />
+ </StyleguideExample>
</template>
- `;
- }
-
- get buttonLinkCode() {
- return `
-import DButton from "discourse/components/d-button";
-
-<template>
- {{#each @dummy.buttonStates as |bs|}}
- <DButton
- @icon="trash-can"
- @translatedLabel={{bs.text}}
- @display="link"
- class={{bs.class}}
- @disabled={{bs.disabled}}
- />
- {{/each}}
-</template>
- `;
- }
-
- get toggleSwitchCode() {
- return `
-import { fn } from "@ember/helper";
-import { on } from "@ember/modifier";
-import DToggleSwitch from "discourse/components/d-toggle-switch";
-import { not } from "discourse/truth-helpers";
-
-<template>
- <DToggleSwitch
- @state={{@dummy.toggleSwitchState}}
- {{on
- "click"
- (fn (mut @dummy.toggleSwitchState) (not @dummy.toggleSwitchState))
- }}
- />
- <DToggleSwitch
- disabled="true"
- @state={{true}}
- title="Disabled with state=true"
- />
- <DToggleSwitch
- disabled="true"
- @state={{false}}
- title="Disabled with state=false"
- />
-</template>
- `;
- }
-
- <template>
- {{this.availableSizes}}
-
- <StyleguideExample
- @title="DButton - icon only - sizes (large, default, small)"
- @code={{this.btnIconSizesCode}}
- >
- {{#each @dummy.buttonSizes as |bs|}}
- <DButton
- @icon="xmark"
- @translatedTitle={{bs.text}}
- @disabled={{bs.disabled}}
- class={{dConcatClass "btn-default" bs.class}}
- />
- {{/each}}
- </StyleguideExample>
-
- <StyleguideExample
- @title="DButton - icon only - states"
- @code={{this.btnIconStatesCode}}
- >
- {{#each @dummy.buttonStates as |bs|}}
- <DButton
- @icon="xmark"
- @translatedTitle={{bs.text}}
- @disabled={{bs.disabled}}
- class={{dConcatClass "btn-default" bs.class}}
- />
- {{/each}}
- </StyleguideExample>
-
- <StyleguideExample
- @title="DButton - text only - sizes (large, default, small)"
- @code={{this.btnTextSizesCode}}
- >
- {{#each @dummy.buttonSizes as |bs|}}
- <DButton
- @translatedLabel={{bs.text}}
- @disabled={{bs.disabled}}
- class={{dConcatClass "btn-default" bs.class}}
- />
- {{/each}}
- </StyleguideExample>
-
- <StyleguideExample
- @title="DButton - text only - states"
- @code={{this.btnTextStatesCode}}
- >
- {{#each @dummy.buttonStates as |bs|}}
- <DButton
- @translatedLabel={{bs.text}}
- @disabled={{bs.disabled}}
- class={{dConcatClass "btn-default" bs.class}}
- />
- {{/each}}
- </StyleguideExample>
-
- <StyleguideExample
- @title="DButton - icon and text - sizes (large, default, small)"
- @code={{this.btnDefaultIconTextSizesCode}}
- >
- {{#each @dummy.buttonSizes as |bs|}}
- <DButton
- @icon="plus"
- @translatedLabel={{bs.text}}
- @disabled={{bs.disabled}}
- class={{dConcatClass "btn-default" bs.class}}
- />
- {{/each}}
- </StyleguideExample>
-
- <StyleguideExample
- @title="DButton - icon and text - states"
- @code={{this.btnDefaultIconTextStatesCode}}
- >
- {{#each @dummy.buttonStates as |bs|}}
- <DButton
- @icon="plus"
- @translatedLabel={{bs.text}}
- @disabled={{bs.disabled}}
- class={{dConcatClass "btn-default" bs.class}}
- />
- {{/each}}
- </StyleguideExample>
-
- <StyleguideExample
- @title="DButton - icon and text - sizes"
- @code={{this.btnPrimaryIconTextSizesCode}}
- >
- {{#each @dummy.buttonSizes as |bs|}}
- <DButton
- @icon="plus"
- @translatedLabel={{bs.text}}
- @disabled={{bs.disabled}}
- class={{dConcatClass "btn-primary" bs.class}}
- />
- {{/each}}
- </StyleguideExample>
-
- <StyleguideExample
- @title="DButton - icon and text - btn-primary - states"
- @code={{this.btnPrimaryIconTextStatesCode}}
- >
- {{#each @dummy.buttonStates as |bs|}}
- <DButton
- @icon="plus"
- @translatedLabel={{bs.text}}
- @disabled={{bs.disabled}}
- class={{dConcatClass "btn-primary" bs.class}}
- />
- {{/each}}
- </StyleguideExample>
-
- <StyleguideExample
- @title="DButton - icon and text - btn-danger - sizes"
- @code={{this.btnDangerIconTextSizesCode}}
- >
- {{#each @dummy.buttonSizes as |bs|}}
- <DButton
- @icon="trash-can"
- @translatedLabel={{bs.text}}
- @disabled={{bs.disabled}}
- class={{dConcatClass "btn-danger" bs.class}}
- />
- {{/each}}
- </StyleguideExample>
-
- <StyleguideExample
- @title="DButton - icon and text - btn-danger - states"
- @code={{this.btnDangerIconTextStatesCode}}
- >
- {{#each @dummy.buttonStates as |bs|}}
- <DButton
- @icon="trash-can"
- @translatedLabel={{bs.text}}
- @disabled={{bs.disabled}}
- class={{dConcatClass "btn-danger" bs.class}}
- />
- {{/each}}
- </StyleguideExample>
-
- <StyleguideExample
- @title="DButton - btn-flat - icon only - sizes"
- @code={{this.btnFlatSizesCode}}
- >
- {{#each @dummy.buttonSizes as |bs|}}
- <DButton
- @icon="trash-can"
- @disabled={{bs.disabled}}
- @translatedTitle={{bs.title}}
- class={{dConcatClass "btn-flat" bs.class}}
- />
- {{/each}}
- </StyleguideExample>
-
- <StyleguideExample
- @title="DButton - btn-flat - states"
- @code={{this.btnFlatStatesCode}}
- >
- {{#each @dummy.buttonStates as |bs|}}
- <DButton
- @icon="trash-can"
- @disabled={{bs.disabled}}
- @translatedLabel={{bs.text}}
- class={{dConcatClass "btn-flat" bs.class}}
- />
- {{/each}}
- </StyleguideExample>
-
- <StyleguideExample
- @title="DButton - btn-transparent - states"
- @code={{this.btnTransparentStatesCode}}
- >
- {{#each @dummy.buttonStates as |bs|}}
- <DButton
- @icon="trash-can"
- @disabled={{bs.disabled}}
- @translatedLabel={{bs.text}}
- class={{dConcatClass "btn-transparent" bs.class}}
- />
- {{/each}}
- </StyleguideExample>
-
- <StyleguideExample @title="DButton - link" @code={{this.buttonLinkCode}}>
- {{#each @dummy.buttonStates as |bs|}}
- <DButton
- @icon="trash-can"
- @translatedLabel={{bs.text}}
- @display="link"
- class={{bs.class}}
- @disabled={{bs.disabled}}
- />
- {{/each}}
- </StyleguideExample>
-
- <StyleguideExample @title="DToggleSwitch" @code={{this.toggleSwitchCode}}>
- <DToggleSwitch
- @state={{@dummy.toggleSwitchState}}
- {{on
- "click"
- (fn (mut @dummy.toggleSwitchState) (not @dummy.toggleSwitchState))
- }}
- />
- <DToggleSwitch
- disabled="true"
- @state={{true}}
- title="Disabled with state=true"
- />
- <DToggleSwitch
- disabled="true"
- @state={{false}}
- title="Disabled with state=false"
- />
- </StyleguideExample>
- </template>
-}
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/04-icons.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/04-icons.gjs
index b1366cd3df3..0aa1636ed50 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/04-icons.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/04-icons.gjs
@@ -4,11 +4,13 @@ import StyleguideExample from "discourse/plugins/styleguide/discourse/components
import StyleguideIcons from "discourse/plugins/styleguide/discourse/components/styleguide-icons";
export default class Icons extends Component {
+ // Curated rather than sourced from a module: the block below renders the whole
+ // sprite gallery, so no example module could ever match what it displays.
get codeSample() {
- return `import icon from "discourse/helpers/d-icon";
+ return `import dIcon from "discourse/ui-kit/helpers/d-icon";
<template>
- {{icon "link"}}
+ {{dIcon "link"}}
</template>`;
}
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/05-forms.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/05-forms.gjs
index eb86c208913..778103e8157 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/05-forms.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/05-forms.gjs
@@ -1,837 +1,159 @@
-import Component from "@glimmer/component";
-import { array, fn, hash } from "@ember/helper";
-import Form from "discourse/components/form";
import StyleguideExample from "discourse/plugins/styleguide/discourse/components/styleguide-example";
-
-export default class Forms extends Component {
- get inputCode() {
- return `import Form from "discourse/components/form";
-
-<template>
- <Form as |form|>
- <form.Field @title="Username" @name="username" @type="input" as |field|>
- <field.Control placeholder="Username" />
- </form.Field>
- <form.Field @title="Age" @name="age" @type="input-number" as |field|>
- <field.Control placeholder="Age" @format="small" />
- </form.Field>
- <form.Field @title="Website" @name="website" @type="input" as |field|>
- <field.Control @before="https://" @after=".com" @format="large" />
- </form.Field>
- <form.Field @title="After" @name="after" @type="input" as |field|>
- <field.Control @after=".com" />
- </form.Field>
- <form.Field @title="Before" @name="before" @type="input" as |field|>
- <field.Control @before="https://" />
- </form.Field>
- <form.Field
- @title="Secret"
- @name="secret"
- @description="An important password"
- @type="password" as |field|
- >
- <field.Control />
- </form.Field>
- </Form>
-</template>`;
- }
-
- get questionCode() {
- return `import Form from "discourse/components/form";
-
-<template>
- <Form as |form|>
- <form.Field @title="Enabled" @name="enabled" @type="question" as |field|>
- <field.Control />
- </form.Field>
- </Form>
-</template>`;
- }
-
- get toggleCode() {
- return `import Form from "discourse/components/form";
-
-<template>
- <Form as |form|>
- <form.Field @title="Enabled" @name="enabled" @type="toggle" as |field|>
- <field.Control />
- </form.Field>
- </Form>
-</template>`;
- }
-
- get composerCode() {
- return `import Form from "discourse/components/form";
-
-<template>
- <Form as |form|>
- <form.Field @title="Query" @name="query" @type="composer" as |field|>
- <field.Control />
- </form.Field>
- </Form>
-</template>`;
- }
-
- get codeCode() {
- return `import Form from "discourse/components/form";
-
-<template>
- <Form as |form|>
- <form.Field @title="Query" @name="query" @type="code" as |field|>
- <field.Control />
- </form.Field>
- </Form>
-</template>`;
- }
-
- get textareaCode() {
- return `import Form from "discourse/components/form";
-
-<template>
- <Form as |form|>
- <form.Field @title="Query" @name="query" @type="textarea" as |field|>
- <field.Control />
- </form.Field>
- </Form>
-</template>`;
- }
-
- get selectCode() {
- return `import Form from "discourse/components/form";
-
-<template>
- <Form as |form|>
- <form.Field @title="Enabled" @name="enabled" @type="select" as |field|>
- <field.Control as |select|>
- <select.Option @value="true">Yes</select.Option>
- <select.Option @value="false">No</select.Option>
- </field.Control>
- </form.Field>
- </Form>
-</template>`;
- }
-
- get checkboxGroupCode() {
- return `import Form from "discourse/components/form";
-
-<template>
- <Form as |form|>
- <form.CheckboxGroup
- @title="I give explicit permission"
- as |checkboxGroup|
- >
- <checkboxGroup.Field
- @title="Use my email for any purpose."
- @name="contract"
- @type="checkbox" as |field|
- >
- <field.Control>Including signing up for services I can't unsubscribe
- to.</field.Control>
- </checkboxGroup.Field>
- <checkboxGroup.Field
- @title="Sign my soul away."
- @name="contract2"
- @type="checkbox" as |field|
- >
- <field.Control>Will severly impact the afterlife experience.</field.Control>
- </checkboxGroup.Field>
- </form.CheckboxGroup>
- </Form>
-</template>`;
- }
-
- get imageCode() {
- return `import Form from "discourse/components/form";
-
-<template>
- <Form as |form|>
- <form.Field @title="Image" @name="image" @type="image" as |field|>
- <field.Control @type="avatar" />
- </form.Field>
- </Form>
-</template>`;
- }
-
- get iconCode() {
- return `import Form from "discourse/components/form";
-
-<template>
- <Form as |form|>
- <form.Field @title="Icon" @name="icon" @type="icon" as |field|>
- <field.Control />
- </form.Field>
- </Form>
-</template>`;
- }
-
- get tagChooserCode() {
- return `import Form from "discourse/components/form";
-
-<template>
- <Form as |form|>
- <form.Field @title="Tags" @name="tags" @type="tag-chooser" as |field|>
- <field.Control />
- </form.Field>
- </Form>
-</template>`;
- }
-
- get menuCode() {
- return `import Form from "discourse/components/form";
-
-<template>
- <Form as |form data|>
- <form.Field @title="Enabled" @name="enabled" @type="menu" as |field|>
- <field.Control @selection={{data.enabled}} as |menu|>
- <menu.Item @value="true">Yes</menu.Item>
- <menu.Divider />
- <menu.Item @value="false">No</menu.Item>
- </field.Control>
- </form.Field>
- </Form>
-</template>`;
- }
-
- get radioGroupCode() {
- return `import Form from "discourse/components/form";
-
-<template>
- <Form as |form|>
- <form.Field @title="Enabled" @name="enabled" @format="full" @type="radio-group" as |field|>
- <field.Control as |radioGroup|>
- <radioGroup.Radio @value="true">Yes</radioGroup.Radio>
- <radioGroup.Radio @value="false" as |radio|>
- <radio.Title>No</radio.Title>
- <radio.Description>
- Choosing no, will make you ineligible for the contest.
- </radio.Description>
- </radioGroup.Radio>
- </field.Control>
- </form.Field>
- </Form>
-</template>`;
- }
-
- get colorCode() {
- return `import Form from "discourse/components/form";
-
-<template>
- <Form as |form|>
- <form.Field @title="Color" @name="color" @type="color" as |field|>
- <field.Control placeholder="RRGGBB" />
- </form.Field>
- </Form>
-</template>`;
- }
-
- get colorWithSwatchesCode() {
- return `import { array } from "@ember/helper";
-import Form from "discourse/components/form";
-
-const COLORS = ["FF0000", "00FF00", "0000FF", "FFFF00", "FF00FF", "00FFFF"];
-const USED_COLORS = ["00FF00"];
-
-<template>
- <Form as |form|>
- <form.Field @title="Color" @name="color" @type="color" as |field|>
- <field.Control
- @colors={{COLORS}}
- @usedColors={{USED_COLORS}}
- placeholder="RRGGBB"
- />
- </form.Field>
- </Form>
-</template>`;
- }
-
- get colorNamedCode() {
- return `import Form from "discourse/components/form";
-
-<template>
- <Form as |form|>
- <form.Field @title="Color" @name="color" @type="color" as |field|>
- <field.Control @allowNamedColors={{true}} placeholder="red, FF0000" />
- </form.Field>
- </Form>
-</template>`;
- }
-
- get colorPrefixHexCode() {
- return `import Form from "discourse/components/form";
-
-<template>
- <Form as |form|>
- <form.Field @title="Color" @name="color" @type="color" as |field|>
- <field.Control @prefixHex={{true}} placeholder="RRGGBB" />
- </form.Field>
- </Form>
-</template>`;
- }
-
- get sectionCode() {
- return `import Form from "discourse/components/form";
-
-<template>
- <Form as |form|>
- <form.Section @title="Section title">
- Content
- </form.Section>
- </Form>
-</template>`;
- }
-
- get alertCode() {
- return `import Form from "discourse/components/form";
-
-<template>
- <Form as |form|>
- <form.Alert @icon="pencil">
- You can edit this form.
- </form.Alert>
- </Form>
-</template>`;
- }
-
- get inputGroupCode() {
- return `import Form from "discourse/components/form";
-
-<template>
- <Form as |form|>
- <form.InputGroup as |inputGroup|>
- <inputGroup.Field @title="Username" @name="username" @type="input" as |field|>
- <field.Control />
- </inputGroup.Field>
- <inputGroup.Field @title="Email" @name="email" @type="input" as |field|>
- <field.Control />
- </inputGroup.Field>
- </form.InputGroup>
- </Form>
-</template>`;
- }
-
- get collectionCode() {
- return `import { array, fn, hash } from "@ember/helper";
-import Form from "discourse/components/form";
-
-<template>
- <Form
- @data={{hash foo=(array (hash bar=1 baz=2) (hash bar=3 baz=4))}}
- as |form|
+import AlertExample from "../../examples/atoms/forms/alert";
+import alertSource from "../../examples/atoms/forms/alert?source=file";
+import CheckboxGroupExample from "../../examples/atoms/forms/checkbox-group";
+import checkboxGroupSource from "../../examples/atoms/forms/checkbox-group?source=file";
+import CodeExample from "../../examples/atoms/forms/code";
+import codeSource from "../../examples/atoms/forms/code?source=file";
+import CollectionExample from "../../examples/atoms/forms/collection";
+import collectionSource from "../../examples/atoms/forms/collection?source=file";
+import ColorExample from "../../examples/atoms/forms/color";
+import colorSource from "../../examples/atoms/forms/color?source=file";
+import ColorNamedExample from "../../examples/atoms/forms/color-named";
+import colorNamedSource from "../../examples/atoms/forms/color-named?source=file";
+import ColorPrefixHexExample from "../../examples/atoms/forms/color-prefix-hex";
+import colorPrefixHexSource from "../../examples/atoms/forms/color-prefix-hex?source=file";
+import ColorSwatchesExample from "../../examples/atoms/forms/color-swatches";
+import colorSwatchesSource from "../../examples/atoms/forms/color-swatches?source=file";
+import ComposerExample from "../../examples/atoms/forms/composer";
+import composerSource from "../../examples/atoms/forms/composer?source=file";
+import IconExample from "../../examples/atoms/forms/icon";
+import iconSource from "../../examples/atoms/forms/icon?source=file";
+import ImageExample from "../../examples/atoms/forms/image";
+import imageSource from "../../examples/atoms/forms/image?source=file";
+import InputExample from "../../examples/atoms/forms/input";
+import inputSource from "../../examples/atoms/forms/input?source=file";
+import InputGroupExample from "../../examples/atoms/forms/input-group";
+import inputGroupSource from "../../examples/atoms/forms/input-group?source=file";
+import MenuExample from "../../examples/atoms/forms/menu";
+import menuSource from "../../examples/atoms/forms/menu?source=file";
+import MultilineExample from "../../examples/atoms/forms/multiline";
+import multilineSource from "../../examples/atoms/forms/multiline?source=file";
+import QuestionExample from "../../examples/atoms/forms/question";
+import questionSource from "../../examples/atoms/forms/question?source=file";
+import RadioGroupExample from "../../examples/atoms/forms/radio-group";
+import radioGroupSource from "../../examples/atoms/forms/radio-group?source=file";
+import RowColExample from "../../examples/atoms/forms/row-col";
+import rowColSource from "../../examples/atoms/forms/row-col?source=file";
+import SectionExample from "../../examples/atoms/forms/section";
+import sectionSource from "../../examples/atoms/forms/section?source=file";
+import SelectExample from "../../examples/atoms/forms/select";
+import selectSource from "../../examples/atoms/forms/select?source=file";
+import TagChooserExample from "../../examples/atoms/forms/tag-chooser";
+import tagChooserSource from "../../examples/atoms/forms/tag-chooser?source=file";
+import TextareaExample from "../../examples/atoms/forms/textarea";
+import textareaSource from "../../examples/atoms/forms/textarea?source=file";
+import ToggleExample from "../../examples/atoms/forms/toggle";
+import toggleSource from "../../examples/atoms/forms/toggle?source=file";
+import ValidationExample from "../../examples/atoms/forms/validation";
+import validationSource from "../../examples/atoms/forms/validation?source=file";
+
+export default <template>
+ <h2>Controls</h2>
+
+ <StyleguideExample @title="Input" @code={{inputSource}}>
+ <InputExample />
+ </StyleguideExample>
+
+ <StyleguideExample @title="Question" @code={{questionSource}}>
+ <QuestionExample />
+ </StyleguideExample>
+
+ <StyleguideExample @title="Toggle" @code={{toggleSource}}>
+ <ToggleExample />
+ </StyleguideExample>
+
+ <StyleguideExample @title="Composer" @code={{composerSource}}>
+ <ComposerExample />
+ </StyleguideExample>
+
+ <StyleguideExample @title="Code" @code={{codeSource}}>
+ <CodeExample />
+ </StyleguideExample>
+
+ <StyleguideExample @title="Textarea" @code={{textareaSource}}>
+ <TextareaExample />
+ </StyleguideExample>
+
+ <StyleguideExample @title="Select" @code={{selectSource}}>
+ <SelectExample />
+ </StyleguideExample>
+
+ <StyleguideExample @title="CheckboxGroup" @code={{checkboxGroupSource}}>
+ <CheckboxGroupExample />
+ </StyleguideExample>
+
+ <StyleguideExample @title="Image" @code={{imageSource}}>
+ <ImageExample />
+ </StyleguideExample>
+
+ <StyleguideExample @title="Icon" @code={{iconSource}}>
+ <IconExample />
+ </StyleguideExample>
+
+ <StyleguideExample @title="TagChooser" @code={{tagChooserSource}}>
+ <TagChooserExample />
+ </StyleguideExample>
+
+ <StyleguideExample @title="Menu" @code={{menuSource}}>
+ <MenuExample />
+ </StyleguideExample>
+
+ <StyleguideExample @title="RadioGroup" @code={{radioGroupSource}}>
+ <RadioGroupExample />
+ </StyleguideExample>
+
+ <StyleguideExample @title="Color" @code={{colorSource}}>
+ <ColorExample />
+ </StyleguideExample>
+
+ <StyleguideExample @title="Color with swatches" @code={{colorSwatchesSource}}>
+ <ColorSwatchesExample />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="Color with named colors"
+ @code={{colorNamedSource}}
>
- <form.Button @action={{fn form.addItemToCollection "foo"}} @icon="plus" />
-
- <form.Collection @name="foo" as |collection index|>
- <form.Row as |row|>
- <row.Col @size={{6}}>
- <collection.Field @title="Bar" @name="bar" @type="input" as |field|>
- <field.Control />
- </collection.Field>
- </row.Col>
-
- <row.Col @size={{4}}>
- <collection.Field @title="Baz" @name="baz" @type="input" as |field|>
- <field.Control />
- </collection.Field>
- </row.Col>
-
- <row.Col @size={{2}}>
- <form.Button @action={{fn collection.remove index}} @icon="minus" />
- </row.Col>
- </form.Row>
- </form.Collection>
-
- </Form>
-</template>`;
- }
-
- get rowColCode() {
- return `import Form from "discourse/components/form";
-
-<template>
- <Form as |form|>
- <form.Row as |row|>
- <row.Col @size={{6}}>
- <form.Field
- @title="Username"
- @name="username"
- @validation="required"
- @type="input" as |field|
- >
- <field.Control />
- </form.Field>
- </row.Col>
- <row.Col @size={{4}}>
- <form.Field @title="Email" @name="email" @type="input" as |field|>
- <field.Control />
- </form.Field>
- </row.Col>
- <row.Col @size={{2}}>
- <form.Submit />
- </row.Col>
- </form.Row>
- </Form>
-</template>`;
- }
-
- get multilineCode() {
- return `import Form from "discourse/components/form";
-
-<template>
- <Form as |form|>
- <form.Row as |row|>
- <row.Col @size={{6}}>
- <form.Field
- @title="Username"
- @name="username"
- @validation="required"
- @type="input" as |field|
- >
- <field.Control />
- </form.Field>
- </row.Col>
- <row.Col @size={{6}}>
- <form.Field @title="Email" @name="email" @type="input" as |field|>
- <field.Control />
- </form.Field>
- </row.Col>
-
- <row.Col @size={{12}}>
- <form.Field @title="Address" @name="address" @type="input" as |field|>
- <field.Control />
- </form.Field>
- </row.Col>
- </form.Row>
- </Form>
-</template>`;
- }
-
- get validationCode() {
- return `import Form from "discourse/components/form";
-
-<template>
- <Form @validateOn="change" as |form|>
- <form.Field
- @title="Username"
- @name="username"
- @validation="required"
- @type="input" as |field|
- >
- <field.Control />
- </form.Field>
-
- <form.Field
- @name="accept_terms"
- @title="Accept terms"
- @validation="required"
- @format="large"
- @type="checkbox" as |field|
- >
- <field.Control />
- </form.Field>
-
- <form.Submit />
- </Form>
-</template>`;
- }
-
- <template>
- <h2>Controls</h2>
- <StyleguideExample @title="Input" @code={{this.inputCode}}>
- <Form as |form|>
- <form.Field @title="Username" @name="username" @type="input" as |field|>
- <field.Control placeholder="Username" />
- </form.Field>
- <form.Field @title="Age" @name="age" @type="input-number" as |field|>
- <field.Control placeholder="Age" @format="small" />
- </form.Field>
- <form.Field @title="Website" @name="website" @type="input" as |field|>
- <field.Control @before="https://" @after=".com" @format="large" />
- </form.Field>
- <form.Field @title="After" @name="after" @type="input" as |field|>
- <field.Control @after=".com" />
- </form.Field>
- <form.Field @title="Before" @name="before" @type="input" as |field|>
- <field.Control @before="https://" />
- </form.Field>
- <form.Field
- @title="Secret"
- @name="secret"
- @description="An important password"
- @type="password"
- as |field|
- >
- <field.Control />
- </form.Field>
- </Form>
- </StyleguideExample>
-
- <StyleguideExample @title="Question" @code={{this.questionCode}}>
- <Form as |form|>
- <form.Field
- @title="Enabled"
- @name="enabled"
- @type="question"
- as |field|
- >
- <field.Control />
- </form.Field>
- </Form>
- </StyleguideExample>
-
- <StyleguideExample @title="Toggle" @code={{this.toggleCode}}>
- <Form as |form|>
- <form.Field @title="Enabled" @name="enabled" @type="toggle" as |field|>
- <field.Control />
- </form.Field>
- </Form>
- </StyleguideExample>
-
- <StyleguideExample @title="Composer" @code={{this.composerCode}}>
- <Form as |form|>
- <form.Field @title="Query" @name="query" @type="composer" as |field|>
- <field.Control />
- </form.Field>
- </Form>
- </StyleguideExample>
+ <ColorNamedExample />
+ </StyleguideExample>
- <StyleguideExample @title="Code" @code={{this.codeCode}}>
- <Form as |form|>
- <form.Field @title="Query" @name="query" @type="code" as |field|>
- <field.Control />
- </form.Field>
- </Form>
- </StyleguideExample>
-
- <StyleguideExample @title="Textarea" @code={{this.textareaCode}}>
- <Form as |form|>
- <form.Field @title="Query" @name="query" @type="textarea" as |field|>
- <field.Control />
- </form.Field>
- </Form>
- </StyleguideExample>
-
- <StyleguideExample @title="Select" @code={{this.selectCode}}>
- <Form as |form|>
- <form.Field @title="Enabled" @name="enabled" @type="select" as |field|>
- <field.Control as |select|>
- <select.Option @value="true">Yes</select.Option>
- <select.Option @value="false">No</select.Option>
- </field.Control>
- </form.Field>
- </Form>
- </StyleguideExample>
-
- <StyleguideExample @title="CheckboxGroup" @code={{this.checkboxGroupCode}}>
- <Form as |form|>
- <form.CheckboxGroup
- @title="I give explicit permission"
- as |checkboxGroup|
- >
- <checkboxGroup.Field
- @title="Use my email for any purpose."
- @name="contract"
- @type="checkbox"
- as |field|
- >
- <field.Control>Including signing up for services I can't unsubscribe
- to.</field.Control>
- </checkboxGroup.Field>
- <checkboxGroup.Field
- @title="Sign my soul away."
- @name="contract2"
- @type="checkbox"
- as |field|
- >
- <field.Control>Will severly impact the afterlife experience.</field.Control>
- </checkboxGroup.Field>
- </form.CheckboxGroup>
- </Form>
- </StyleguideExample>
-
- <StyleguideExample @title="Image" @code={{this.imageCode}}>
- <Form as |form|>
- <form.Field @title="Image" @name="image" @type="image" as |field|>
- <field.Control @type="avatar" />
- </form.Field>
- </Form>
- </StyleguideExample>
-
- <StyleguideExample @title="Icon" @code={{this.iconCode}}>
- <Form as |form|>
- <form.Field @title="Icon" @name="icon" @type="icon" as |field|>
- <field.Control />
- </form.Field>
- </Form>
- </StyleguideExample>
-
- <StyleguideExample @title="TagChooser" @code={{this.tagChooserCode}}>
- <Form as |form|>
- <form.Field @title="Tags" @name="tags" @type="tag-chooser" as |field|>
- <field.Control />
- </form.Field>
- </Form>
- </StyleguideExample>
-
- <StyleguideExample @title="Menu" @code={{this.menuCode}}>
- <Form as |form data|>
- <form.Field @title="Enabled" @name="enabled" @type="menu" as |field|>
- <field.Control @selection={{data.enabled}} as |menu|>
- <menu.Item @value="true">Yes</menu.Item>
- <menu.Divider />
- <menu.Item @value="false">No</menu.Item>
- </field.Control>
- </form.Field>
- </Form>
- </StyleguideExample>
-
- <StyleguideExample @title="RadioGroup" @code={{this.radioGroupCode}}>
- <Form as |form|>
- <form.Field
- @title="Enabled"
- @name="enabled"
- @format="full"
- @type="radio-group"
- as |field|
- >
- <field.Control as |radioGroup|>
- <radioGroup.Radio @value="true">Yes</radioGroup.Radio>
- <radioGroup.Radio @value="false" as |radio|>
- <radio.Title>No</radio.Title>
- <radio.Description>
- Choosing no, will make you ineligible for the contest.
- </radio.Description>
- </radioGroup.Radio>
- </field.Control>
- </form.Field>
- </Form>
- </StyleguideExample>
-
- <StyleguideExample @title="Color" @code={{this.colorCode}}>
- <Form as |form|>
- <form.Field @title="Color" @name="color" @type="color" as |field|>
- <field.Control placeholder="RRGGBB" />
- </form.Field>
- </Form>
- </StyleguideExample>
-
- <StyleguideExample
- @title="Color with swatches"
- @code={{this.colorWithSwatchesCode}}
- >
- <Form as |form|>
- <form.Field @title="Color" @name="color" @type="color" as |field|>
- <field.Control
- @colors={{array
- "FF0000"
- "00FF00"
- "0000FF"
- "FFFF00"
- "FF00FF"
- "00FFFF"
- }}
- @usedColors={{array "00FF00"}}
- placeholder="RRGGBB"
- />
- </form.Field>
- </Form>
- </StyleguideExample>
-
- <StyleguideExample
- @title="Color with named colors"
- @code={{this.colorNamedCode}}
- >
- <Form as |form|>
- <form.Field @title="Color" @name="color" @type="color" as |field|>
- <field.Control @allowNamedColors={{true}} placeholder="red, FF0000" />
- </form.Field>
- </Form>
- </StyleguideExample>
-
- <StyleguideExample
- @title="Color with # prefix in value"
- @code={{this.colorPrefixHexCode}}
- >
- <Form as |form|>
- <form.Field @title="Color" @name="color" @type="color" as |field|>
- <field.Control @prefixHex={{true}} placeholder="RRGGBB" />
- </form.Field>
- </Form>
- </StyleguideExample>
-
- <h2>Layout</h2>
-
- <StyleguideExample @title="Section" @code={{this.sectionCode}}>
- <Form as |form|>
- <form.Section @title="Section title">
- Content
- </form.Section>
- </Form>
- </StyleguideExample>
-
- <StyleguideExample @title="Alert" @code={{this.alertCode}}>
- <Form as |form|>
- <form.Alert @icon="pencil">
- You can edit this form.
- </form.Alert>
- </Form>
- </StyleguideExample>
-
- <StyleguideExample @title="InputGroup" @code={{this.inputGroupCode}}>
- <Form as |form|>
- <form.InputGroup as |inputGroup|>
- <inputGroup.Field
- @title="Username"
- @name="username"
- @type="input"
- as |field|
- >
- <field.Control />
- </inputGroup.Field>
- <inputGroup.Field
- @title="Email"
- @name="email"
- @type="input"
- as |field|
- >
- <field.Control />
- </inputGroup.Field>
- </form.InputGroup>
- </Form>
- </StyleguideExample>
-
- <StyleguideExample @title="Collection" @code={{this.collectionCode}}>
- <Form
- @data={{hash foo=(array (hash bar=1 baz=2) (hash bar=3 baz=4))}}
- as |form|
- >
- <form.Button
- @action={{fn form.addItemToCollection "foo"}}
- @icon="plus"
- />
-
- <form.Collection @name="foo" as |collection index|>
- <form.Row as |row|>
- <row.Col @size={{6}}>
- <collection.Field
- @title="Bar"
- @name="bar"
- @type="input"
- as |field|
- >
- <field.Control />
- </collection.Field>
- </row.Col>
-
- <row.Col @size={{4}}>
- <collection.Field
- @title="Baz"
- @name="baz"
- @type="input"
- as |field|
- >
- <field.Control />
- </collection.Field>
- </row.Col>
+ <StyleguideExample
+ @title="Color with # prefix in value"
+ @code={{colorPrefixHexSource}}
+ >
+ <ColorPrefixHexExample />
+ </StyleguideExample>
- <row.Col @size={{2}}>
- <form.Button
- @action={{fn collection.remove index}}
- @icon="minus"
- />
- </row.Col>
- </form.Row>
- </form.Collection>
+ <h2>Layout</h2>
- </Form>
- </StyleguideExample>
+ <StyleguideExample @title="Section" @code={{sectionSource}}>
+ <SectionExample />
+ </StyleguideExample>
- <StyleguideExample @title="Row/Col" @code={{this.rowColCode}}>
- <Form as |form|>
- <form.Row as |row|>
- <row.Col @size={{6}}>
- <form.Field
- @title="Username"
- @name="username"
- @validation="required"
- @type="input"
- as |field|
- >
- <field.Control />
- </form.Field>
- </row.Col>
- <row.Col @size={{4}}>
- <form.Field @title="Email" @name="email" @type="input" as |field|>
- <field.Control />
- </form.Field>
- </row.Col>
- <row.Col @size={{2}}>
- <form.Submit />
- </row.Col>
- </form.Row>
- </Form>
- </StyleguideExample>
+ <StyleguideExample @title="Alert" @code={{alertSource}}>
+ <AlertExample />
+ </StyleguideExample>
- <StyleguideExample @title="Multiline" @code={{this.multilineCode}}>
- <Form as |form|>
- <form.Row as |row|>
- <row.Col @size={{6}}>
- <form.Field
- @title="Username"
- @name="username"
- @validation="required"
- @type="input"
- as |field|
- >
- <field.Control />
- </form.Field>
- </row.Col>
- <row.Col @size={{6}}>
- <form.Field @title="Email" @name="email" @type="input" as |field|>
- <field.Control />
- </form.Field>
- </row.Col>
+ <StyleguideExample @title="InputGroup" @code={{inputGroupSource}}>
+ <InputGroupExample />
+ </StyleguideExample>
- <row.Col @size={{12}}>
- <form.Field
- @title="Address"
- @name="address"
- @type="input"
- as |field|
- >
- <field.Control />
- </form.Field>
- </row.Col>
- </form.Row>
- </Form>
- </StyleguideExample>
+ <StyleguideExample @title="Collection" @code={{collectionSource}}>
+ <CollectionExample />
+ </StyleguideExample>
- <h2>Validation</h2>
+ <StyleguideExample @title="Row/Col" @code={{rowColSource}}>
+ <RowColExample />
+ </StyleguideExample>
- <StyleguideExample @title="Input" @code={{this.validationCode}}>
- <Form @validateOn="change" as |form|>
- <form.Field
- @title="Username"
- @name="username"
- @validation="required"
- @type="input"
- as |field|
- >
- <field.Control />
- </form.Field>
+ <StyleguideExample @title="Multiline" @code={{multilineSource}}>
+ <MultilineExample />
+ </StyleguideExample>
- <form.Field
- @name="accept_terms"
- @title="Accept terms"
- @validation="required"
- @format="large"
- @type="checkbox"
- as |field|
- >
- <field.Control />
- </form.Field>
+ <h2>Validation</h2>
- <form.Submit />
- </Form>
- </StyleguideExample>
- </template>
-}
+ <StyleguideExample @title="Input" @code={{validationSource}}>
+ <ValidationExample />
+ </StyleguideExample>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/06-spinners.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/06-spinners.gjs
index 9e18ecd9ba6..16bcf0c9a11 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/06-spinners.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/06-spinners.gjs
@@ -1,23 +1,15 @@
-import Component from "@glimmer/component";
import StyleguideExample from "discourse/plugins/styleguide/discourse/components/styleguide-example";
-import SpinnerSmallExample from "../../examples/spinner-small";
-import spinnerSmallSource from "../../examples/spinner-small.gjs?source=template";
+import SpinnerRegularExample from "../../examples/atoms/spinners/regular";
+import spinnerRegularSource from "../../examples/atoms/spinners/regular?source=template";
+import SpinnerSmallExample from "../../examples/atoms/spinners/small";
+import spinnerSmallSource from "../../examples/atoms/spinners/small?source=template";
-export default class Spinners extends Component {
- get spinnerRegularCode() {
- return `<div class="spinner"></div>`;
- }
+export default <template>
+ <StyleguideExample @title="spinner - small" @code={{spinnerSmallSource}}>
+ <SpinnerSmallExample />
+ </StyleguideExample>
- <template>
- <StyleguideExample @title="spinner - small" @code={{spinnerSmallSource}}>
- <SpinnerSmallExample />
- </StyleguideExample>
-
- <StyleguideExample
- @title="spinner - regular"
- @code={{this.spinnerRegularCode}}
- >
- <div class="spinner"></div>
- </StyleguideExample>
- </template>
-}
+ <StyleguideExample @title="spinner - regular" @code={{spinnerRegularSource}}>
+ <SpinnerRegularExample />
+ </StyleguideExample>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/07-otp.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/07-otp.gjs
index a29b6871895..8a2393ef4a2 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/07-otp.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/07-otp.gjs
@@ -1,64 +1,15 @@
-import Component from "@glimmer/component";
-import { tracked } from "@glimmer/tracking";
-import { action } from "@ember/object";
-import DOtp from "discourse/ui-kit/d-otp";
import StyleguideExample from "discourse/plugins/styleguide/discourse/components/styleguide-example";
-
-export default class OTP extends Component {
- @tracked filledOutput;
- @tracked changedOutput;
-
- @action
- filled(otp) {
- this.filledOutput = `filled: ${otp}`;
- }
-
- @action
- changed(otp) {
- this.filledOutput = null;
-
- if (otp.length) {
- this.changedOutput = `changed: ${otp}`;
- } else {
- this.changedOutput = null;
- }
- }
-
- get codeSample1() {
- return `import DOTP from "discourse/components/d-otp";
-
-<template>
- <DOTP @onFill={{this.filled}} @onChange={{this.changed}} />
-</template>`;
- }
-
- get codeSample2() {
- return `import DOTP from "discourse/components/d-otp";
-
-<template>
- <DOTP @slots={{4}} />
-</template>`;
- }
-
- <template>
- <StyleguideExample @title="DOTP" @code={{this.codeSample1}}>
- <DOtp @onFill={{this.filled}} @onChange={{this.changed}} />
-
- {{#if this.changedOutput}}
- <output>
- {{#if this.changedOutput}}
- <p>{{this.changedOutput}}</p>
- {{/if}}
-
- {{#if this.filledOutput}}
- <p>{{this.filledOutput}}</p>
- {{/if}}
- </output>
- {{/if}}
- </StyleguideExample>
-
- <StyleguideExample @title="DOTP @slots={{4}}" @code={{this.codeSample2}}>
- <DOtp @slots={{4}} />
- </StyleguideExample>
- </template>
-}
+import CallbacksExample from "../../examples/atoms/otp/callbacks";
+import callbacksSource from "../../examples/atoms/otp/callbacks?source=file";
+import SlotsExample from "../../examples/atoms/otp/slots";
+import slotsSource from "../../examples/atoms/otp/slots?source=file";
+
+export default <template>
+ <StyleguideExample @title="DOtp" @code={{callbacksSource}}>
+ <CallbacksExample />
+ </StyleguideExample>
+
+ <StyleguideExample @title="DOtp @slots={{4}}" @code={{slotsSource}}>
+ <SlotsExample />
+ </StyleguideExample>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/08-date-time-inputs.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/08-date-time-inputs.gjs
index f29c6b80fd6..e3132971f6d 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/08-date-time-inputs.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/08-date-time-inputs.gjs
@@ -1,122 +1,54 @@
-import Component from "@glimmer/component";
-import DDateInput from "discourse/ui-kit/d-date-input";
-import DDatePicker from "discourse/ui-kit/d-date-picker";
-import DDateTimeInput from "discourse/ui-kit/d-date-time-input";
-import DDateTimeInputRange from "discourse/ui-kit/d-date-time-input-range";
-import DFutureDateInput from "discourse/ui-kit/d-future-date-input";
-import DTimeInput from "discourse/ui-kit/d-time-input";
import CalendarDateTimeInput from "discourse/plugins/styleguide/discourse/components/styleguide/calendar-date-time-input";
import StyleguideExample from "discourse/plugins/styleguide/discourse/components/styleguide-example";
-
-export default class DateTimeInputs extends Component {
- get timeInputCode() {
- return `
-import TimeInput from "discourse/components/time-input";
-
-<template>
- <TimeInput />
-</template>
- `;
- }
-
- get dateInputCode() {
- return `
-import DateInput from "discourse/components/date-input";
-
-<template>
- <DateInput />
-</template>
- `;
- }
-
- get dateTimeInputCode() {
- return `
-import DateTimeInput from "discourse/components/date-time-input";
-
-<template>
- <DateTimeInput @clearable={{true}} />
-</template>
- `;
- }
-
- get dateTimeInputRangeCode() {
- return `
-import DateTimeInputRange from "discourse/components/date-time-input-range";
-
-<template>
- <DateTimeInputRange />
-</template>
- `;
- }
-
- get dateTimeInputRangeNoTimeCode() {
- return `
-import DateTimeInputRange from "discourse/components/date-time-input-range";
-
-<template>
- <DateTimeInputRange @showFromTime={{false}} @showToTime={{false}} />
+import DateInputExample from "../../examples/atoms/date-time-inputs/date-input";
+import dateInputSource from "../../examples/atoms/date-time-inputs/date-input?source=file";
+import DatePickerExample from "../../examples/atoms/date-time-inputs/date-picker";
+import datePickerSource from "../../examples/atoms/date-time-inputs/date-picker?source=file";
+import DateTimeInputExample from "../../examples/atoms/date-time-inputs/date-time-input";
+import dateTimeInputSource from "../../examples/atoms/date-time-inputs/date-time-input?source=file";
+import DateTimeInputRangeExample from "../../examples/atoms/date-time-inputs/date-time-input-range";
+import dateTimeInputRangeSource from "../../examples/atoms/date-time-inputs/date-time-input-range?source=file";
+import DateTimeInputRangeWithoutTimeExample from "../../examples/atoms/date-time-inputs/date-time-input-range-without-time";
+import dateTimeInputRangeWithoutTimeSource from "../../examples/atoms/date-time-inputs/date-time-input-range-without-time?source=file";
+import FutureDateInputExample from "../../examples/atoms/date-time-inputs/future-date-input";
+import futureDateInputSource from "../../examples/atoms/date-time-inputs/future-date-input?source=file";
+import TimeInputExample from "../../examples/atoms/date-time-inputs/time-input";
+import timeInputSource from "../../examples/atoms/date-time-inputs/time-input?source=file";
+
+export default <template>
+ <StyleguideExample @title="TimeInput" @code={{timeInputSource}}>
+ <TimeInputExample />
+ </StyleguideExample>
+
+ <StyleguideExample @title="DateInput" @code={{dateInputSource}}>
+ <DateInputExample />
+ </StyleguideExample>
+
+ <StyleguideExample @title="DateTimeInput" @code={{dateTimeInputSource}}>
+ <DateTimeInputExample />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="DateTimeInputRange"
+ @code={{dateTimeInputRangeSource}}
+ >
+ <DateTimeInputRangeExample />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="DateTimeInputRange without time"
+ @code={{dateTimeInputRangeWithoutTimeSource}}
+ >
+ <DateTimeInputRangeWithoutTimeExample />
+ </StyleguideExample>
+
+ <StyleguideExample @title="FutureDateInput" @code={{futureDateInputSource}}>
+ <FutureDateInputExample />
+ </StyleguideExample>
+
+ <StyleguideExample @title="DatePicker" @code={{datePickerSource}}>
+ <DatePickerExample />
+ </StyleguideExample>
+
+ <CalendarDateTimeInput />
</template>
- `;
- }
-
- get futureDateInputCode() {
- return `
-import FutureDateInput from "discourse/components/future-date-input";
-
-<template>
- <FutureDateInput @displayLabelIcon="far-clock" @clearable={{true}} />
-</template>
- `;
- }
-
- get datePickerCode() {
- return `
-import DatePicker from "discourse/components/date-picker";
-
-<template>
- <DatePicker @defaultDate="YYYY-MM-DD" />
-</template>
- `;
- }
-
- <template>
- <StyleguideExample @title="TimeInput" @code={{this.timeInputCode}}>
- <DTimeInput />
- </StyleguideExample>
-
- <StyleguideExample @title="DateInput" @code={{this.dateInputCode}}>
- <DDateInput />
- </StyleguideExample>
-
- <StyleguideExample @title="DateTimeInput" @code={{this.dateTimeInputCode}}>
- <DDateTimeInput @clearable={{true}} />
- </StyleguideExample>
-
- <StyleguideExample
- @title="DateTimeInputRange"
- @code={{this.dateTimeInputRangeCode}}
- >
- <DDateTimeInputRange />
- </StyleguideExample>
-
- <StyleguideExample
- @title="DateTimeInputRange without time"
- @code={{this.dateTimeInputRangeNoTimeCode}}
- >
- <DDateTimeInputRange @showFromTime={{false}} @showToTime={{false}} />
- </StyleguideExample>
-
- <StyleguideExample
- @title="FutureDateInput"
- @code={{this.futureDateInputCode}}
- >
- <DFutureDateInput @displayLabelIcon="far-clock" @clearable={{true}} />
- </StyleguideExample>
-
- <StyleguideExample @title="DatePicker" @code={{this.datePickerCode}}>
- <DDatePicker @defaultDate="YYYY-MM-DD" />
- </StyleguideExample>
-
- <CalendarDateTimeInput />
- </template>
-}
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/09-dropdowns.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/09-dropdowns.gjs
index 90ecab4df5d..f1f53019049 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/09-dropdowns.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/09-dropdowns.gjs
@@ -1,491 +1,160 @@
-import Component from "@glimmer/component";
-import { fn, get, hash } from "@ember/helper";
-import CategoryNotificationsTracking from "discourse/components/category-notifications-tracking";
-import PinnedButton from "discourse/components/pinned-button";
-import PinnedOptions from "discourse/components/pinned-options";
-import TopicNotificationsTracking from "discourse/components/topic-notifications-tracking";
-import CategoriesAdminDropdown from "discourse/select-kit/components/categories-admin-dropdown";
-import CategoryChooser from "discourse/select-kit/components/category-chooser";
-import ComboBox from "discourse/select-kit/components/combo-box";
-import DropdownSelectBox from "discourse/select-kit/components/dropdown-select-box";
-import FutureDateInputSelector from "discourse/select-kit/components/future-date-input-selector";
-import GroupChooser from "discourse/select-kit/components/group-chooser";
-import ListSetting from "discourse/select-kit/components/list-setting";
-import MiniTagChooser from "discourse/select-kit/components/mini-tag-chooser";
-import MultiSelect from "discourse/select-kit/components/multi-select";
-import UserNotificationsDropdown from "discourse/select-kit/components/user-notifications-dropdown";
-import DIconGridPicker from "discourse/ui-kit/d-icon-grid-picker";
import StyleguideExample from "discourse/plugins/styleguide/discourse/components/styleguide-example";
-
-export default class Dropdowns extends Component {
- get comboBoxCode() {
- return `
-import { fn } from "@ember/helper";
-import { mut } from "discourse/helpers/mut";
-import ComboBox from "discourse/select-kit/components/combo-box";
-
-<template>
- <ComboBox
- @content={{@dummy.options}}
- @value={{value}}
- @onChange={{fn (mut value)}}
- />
-</template>
- `;
- }
-
- get comboBoxFilterableCode() {
- return `
-import { fn, hash } from "@ember/helper";
-import { mut } from "discourse/helpers/mut";
-import ComboBox from "discourse/select-kit/components/combo-box";
-
-<template>
- <ComboBox
- @content={{@dummy.categories}}
- @value={{value}}
- @options={{hash filterable=true}}
- @onChange={{fn (mut value)}}
- />
-</template>
- `;
- }
-
- get comboBoxDefaultStateCode() {
- return `
-import { fn, hash } from "@ember/helper";
-import { mut } from "discourse/helpers/mut";
-import ComboBox from "discourse/select-kit/components/combo-box";
-
-<template>
- <ComboBox
- @content={{@dummy.options}}
- @value={{value}}
- @options={{hash none="category.none"}}
- @onChange={{fn (mut value)}}
- />
-</template>
- `;
- }
-
- get comboBoxClearableCode() {
- return `
-import { fn, hash } from "@ember/helper";
-import { mut } from "discourse/helpers/mut";
-import ComboBox from "discourse/select-kit/components/combo-box";
-
-<template>
- <ComboBox
- @content={{@dummy.options}}
- @clearable={{true}}
- @value={{value}}
- @options={{hash none="category.none"}}
- @onChange={{fn (mut value)}}
- />
-</template>
- `;
- }
-
- get topicNotificationsTrackingCode() {
- return `
-import { fn } from "@ember/helper";
-import { mut } from "discourse/helpers/mut";
-import TopicNotificationsTracking from "discourse/components/topic-notifications-tracking";
-
-<template>
- <TopicNotificationsTracking
- @levelId={{value}}
- @onChange={{fn (mut value)}}
- />
-</template>
- `;
- }
-
- get categoryChooserCode() {
- return `
-import { fn } from "@ember/helper";
-import { mut } from "discourse/helpers/mut";
-import CategoryChooser from "discourse/select-kit/components/category-chooser";
-
-<template>
- <CategoryChooser @value={{value}} @onChange={{fn (mut value)}} />
-</template>
- `;
- }
-
- get pinnedButtonCode() {
- return `
-import PinnedButton from "discourse/components/pinned-button";
-
-<template>
- <PinnedButton @topic={{@dummy.pinnedTopic}} @pinned={{true}} />
+import CategoriesAdminDropdownExample from "../../examples/atoms/dropdowns/categories-admin-dropdown";
+import categoriesAdminDropdownSource from "../../examples/atoms/dropdowns/categories-admin-dropdown?source=file";
+import CategoryChooserExample from "../../examples/atoms/dropdowns/category-chooser";
+import categoryChooserSource from "../../examples/atoms/dropdowns/category-chooser?source=file";
+import CategoryNotificationsTrackingExample from "../../examples/atoms/dropdowns/category-notifications-tracking";
+import categoryNotificationsTrackingSource from "../../examples/atoms/dropdowns/category-notifications-tracking?source=file";
+import ComboBoxExample from "../../examples/atoms/dropdowns/combo-box";
+import comboBoxSource from "../../examples/atoms/dropdowns/combo-box?source=file";
+import ComboBoxClearableExample from "../../examples/atoms/dropdowns/combo-box-clearable";
+import comboBoxClearableSource from "../../examples/atoms/dropdowns/combo-box-clearable?source=file";
+import ComboBoxFilterableExample from "../../examples/atoms/dropdowns/combo-box-filterable";
+import comboBoxFilterableSource from "../../examples/atoms/dropdowns/combo-box-filterable?source=file";
+import ComboBoxNoneExample from "../../examples/atoms/dropdowns/combo-box-none";
+import comboBoxNoneSource from "../../examples/atoms/dropdowns/combo-box-none?source=file";
+import DropdownSelectBoxExample from "../../examples/atoms/dropdowns/dropdown-select-box";
+import dropdownSelectBoxSource from "../../examples/atoms/dropdowns/dropdown-select-box?source=file";
+import FutureDateInputSelectorExample from "../../examples/atoms/dropdowns/future-date-input-selector";
+import futureDateInputSelectorSource from "../../examples/atoms/dropdowns/future-date-input-selector?source=file";
+import GroupChooserExample from "../../examples/atoms/dropdowns/group-chooser";
+import groupChooserSource from "../../examples/atoms/dropdowns/group-chooser?source=file";
+import IconGridPickerExample from "../../examples/atoms/dropdowns/icon-grid-picker";
+import iconGridPickerSource from "../../examples/atoms/dropdowns/icon-grid-picker?source=file";
+import ListSettingExample from "../../examples/atoms/dropdowns/list-setting";
+import listSettingSource from "../../examples/atoms/dropdowns/list-setting?source=file";
+import ListSettingNamePropertyExample from "../../examples/atoms/dropdowns/list-setting-name-property";
+import listSettingNamePropertySource from "../../examples/atoms/dropdowns/list-setting-name-property?source=file";
+import MiniTagChooserExample from "../../examples/atoms/dropdowns/mini-tag-chooser";
+import miniTagChooserSource from "../../examples/atoms/dropdowns/mini-tag-chooser?source=file";
+import MiniTagChooserHeaderFilterExample from "../../examples/atoms/dropdowns/mini-tag-chooser-header-filter";
+import miniTagChooserHeaderFilterSource from "../../examples/atoms/dropdowns/mini-tag-chooser-header-filter?source=file";
+import MultiSelectExample from "../../examples/atoms/dropdowns/multi-select";
+import multiSelectSource from "../../examples/atoms/dropdowns/multi-select?source=file";
+import PinnedButtonExample from "../../examples/atoms/dropdowns/pinned-button";
+import pinnedButtonSource from "../../examples/atoms/dropdowns/pinned-button?source=file";
+import PinnedOptionsExample from "../../examples/atoms/dropdowns/pinned-options";
+import pinnedOptionsSource from "../../examples/atoms/dropdowns/pinned-options?source=file";
+import TopicNotificationsTrackingExample from "../../examples/atoms/dropdowns/topic-notifications-tracking";
+import topicNotificationsTrackingSource from "../../examples/atoms/dropdowns/topic-notifications-tracking?source=file";
+import UserNotificationsDropdownExample from "../../examples/atoms/dropdowns/user-notifications-dropdown";
+import userNotificationsDropdownSource from "../../examples/atoms/dropdowns/user-notifications-dropdown?source=file";
+
+export default <template>
+ <StyleguideExample @title="<ComboBox>" @code={{comboBoxSource}}>
+ <ComboBoxExample />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="filterable <ComboBox>"
+ @code={{comboBoxFilterableSource}}
+ >
+ <ComboBoxFilterableExample @categories={{@dummy.categories}} />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="<ComboBox> with a default state"
+ @code={{comboBoxNoneSource}}
+ >
+ <ComboBoxNoneExample />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="<ComboBox> clearable"
+ @code={{comboBoxClearableSource}}
+ >
+ <ComboBoxClearableExample />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="<TopicNotificationsTracking>"
+ @code={{topicNotificationsTrackingSource}}
+ >
+ <TopicNotificationsTrackingExample />
+ </StyleguideExample>
+
+ <StyleguideExample @title="<CategoryChooser>" @code={{categoryChooserSource}}>
+ <CategoryChooserExample />
+ </StyleguideExample>
+
+ <StyleguideExample @title="<PinnedButton>" @code={{pinnedButtonSource}}>
+ <PinnedButtonExample @topic={{@dummy.pinnedTopic}} />
+ </StyleguideExample>
+
+ <StyleguideExample @title="<PinnedOptions>" @code={{pinnedOptionsSource}}>
+ <PinnedOptionsExample @topic={{@dummy.pinnedTopic}} />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="<CategoriesAdminDropdown>"
+ @code={{categoriesAdminDropdownSource}}
+ >
+ <CategoriesAdminDropdownExample @onChange={{@dummyAction}} />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="<CategoryNotificationsTracking>"
+ @code={{categoryNotificationsTrackingSource}}
+ >
+ <CategoryNotificationsTrackingExample @onChange={{@dummyAction}} />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="<DropdownSelectBox>"
+ @code={{dropdownSelectBoxSource}}
+ >
+ <DropdownSelectBoxExample @onChange={{@dummyAction}} />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="<FutureDateInputSelector>"
+ @code={{futureDateInputSelectorSource}}
+ >
+ <FutureDateInputSelectorExample />
+ </StyleguideExample>
+
+ <StyleguideExample @title="<MultiSelect>" @code={{multiSelectSource}}>
+ <MultiSelectExample @onChange={{@dummyAction}} />
+ </StyleguideExample>
+
+ <StyleguideExample @title="<MiniTagChooser>" @code={{miniTagChooserSource}}>
+ <div class="inline-form">
+ <MiniTagChooserExample />
+ </div>
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="<MiniTagChooser> with useHeaderFilter=true"
+ @code={{miniTagChooserHeaderFilterSource}}
+ >
+ <div class="inline-form">
+ <MiniTagChooserHeaderFilterExample />
+ </div>
+ </StyleguideExample>
+
+ <StyleguideExample @title="admin <GroupChooser>" @code={{groupChooserSource}}>
+ <GroupChooserExample @onChange={{@dummyAction}} />
+ </StyleguideExample>
+
+ <StyleguideExample @title="<ListSetting>" @code={{listSettingSource}}>
+ <ListSettingExample @onChange={{@dummyAction}} />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="<ListSetting> with a name property"
+ @code={{listSettingNamePropertySource}}
+ >
+ <ListSettingNamePropertyExample @onChange={{@dummyAction}} />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="<UserNotificationsDropdown>"
+ @code={{userNotificationsDropdownSource}}
+ >
+ <UserNotificationsDropdownExample />
+ </StyleguideExample>
+
+ <StyleguideExample @title="<DIconGridPicker>" @code={{iconGridPickerSource}}>
+ <IconGridPickerExample />
+ </StyleguideExample>
</template>
- `;
- }
-
- get pinnedOptionsCode() {
- return `
-import PinnedOptions from "discourse/components/pinned-options";
-
-<template>
- <PinnedOptions @topic={{@dummy.pinnedTopic}} />
-</template>
- `;
- }
-
- get categoriesAdminDropdownCode() {
- return `
-import CategoriesAdminDropdown from "discourse/select-kit/components/categories-admin-dropdown";
-
-<template>
- <CategoriesAdminDropdown @onChange={{@dummyAction}} />
-</template>
- `;
- }
-
- get categoryNotificationsTrackingCode() {
- return `
-import CategoryNotificationsTracking from "discourse/components/category-notifications-tracking";
-
-<template>
- <CategoryNotificationsTracking @levelId={{1}} @onChange={{@dummyAction}} />
-</template>
- `;
- }
-
- get dropdownSelectBoxCode() {
- return `
-import { hash } from "@ember/helper";
-import DropdownSelectBox from "discourse/select-kit/components/dropdown-select-box";
-
-<template>
- <DropdownSelectBox
- @content={{@dummy.options}}
- @onChange={{@dummyAction}}
- @options={{hash translatedNone="Something"}}
- />
-</template>
- `;
- }
-
- get futureDateInputSelectorCode() {
- return `
-import { hash } from "@ember/helper";
-import FutureDateInputSelector from "discourse/select-kit/components/future-date-input-selector";
-
-<template>
- <FutureDateInputSelector
- @input={{@dummy.topicTimerUpdateDate}}
- @includeWeekend={{true}}
- @includeForever={{true}}
- @options={{hash none="time_shortcut.select_timeframe"}}
- />
-</template>
- `;
- }
-
- get multiSelectCode() {
- return `
-import MultiSelect from "discourse/select-kit/components/multi-select";
-
-<template>
- <MultiSelect @content={{@dummy.options}} @onChange={{@dummyAction}} />
-</template>
- `;
- }
-
- get miniTagChooserCode() {
- return `
-import { hash } from "@ember/helper";
-import MiniTagChooser from "discourse/select-kit/components/mini-tag-chooser";
-
-<template>
- <MiniTagChooser
- @value={{@dummy.selectedTags}}
- @options={{hash filterable=true}}
- />
-</template>
- `;
- }
-
- get miniTagChooserHeaderFilterCode() {
- return `
-import { hash } from "@ember/helper";
-import MiniTagChooser from "discourse/select-kit/components/mini-tag-chooser";
-
-<template>
- <MiniTagChooser
- @value={{@dummy.selectedTags}}
- @options={{hash
- filterable=true
- filterPlaceholder="tagging.choose_for_topic"
- useHeaderFilter=true
- }}
- />
-</template>
- `;
- }
-
- get groupChooserCode() {
- return `
-import GroupChooser from "discourse/select-kit/components/group-chooser";
-
-<template>
- <GroupChooser
- @selected={{@dummy.selectedGroups}}
- @content={{@dummy.groups}}
- @onChange={{@dummyAction}}
- />
-</template>
- `;
- }
-
- get listSettingCode() {
- return `
-import ListSetting from "discourse/select-kit/components/list-setting";
-
-<template>
- <ListSetting @settingValue={{@dummy.settings}} @onChange={{@dummyAction}} />
-</template>
- `;
- }
-
- get listSettingNamePropertyCode() {
- return `
-import ListSetting from "discourse/select-kit/components/list-setting";
-
-<template>
- <ListSetting
- @settingValue={{@dummy.colors}}
- @nameProperty="color"
- @onChange={{@dummyAction}}
- />
-</template>
- `;
- }
-
- get userNotificationsDropdownCode() {
- return `
-import UserNotificationsDropdown from "discourse/select-kit/components/user-notifications-dropdown";
-
-<template>
- <UserNotificationsDropdown @user={{@currentUser}} @value="changeToNormal" />
-</template>
- `;
- }
-
- get iconPickerCode() {
- return `
-import DIconGridPicker from "discourse/components/d-icon-grid-picker";
-
-<template>
- <DIconGridPicker />
-</template>
- `;
- }
-
- <template>
- <StyleguideExample
- @title="<ComboBox>"
- @code={{this.comboBoxCode}}
- @initialValue={{get @dummy "options.0.name"}}
- as |value|
- >
- <ComboBox
- @content={{@dummy.options}}
- @value={{value}}
- @onChange={{fn (mut value)}}
- />
- </StyleguideExample>
-
- <StyleguideExample
- @title="filterable <ComboBox>"
- @code={{this.comboBoxFilterableCode}}
- @initialValue={{get @dummy "categories.0.name"}}
- as |value|
- >
- <ComboBox
- @content={{@dummy.categories}}
- @value={{value}}
- @options={{hash filterable=true}}
- @onChange={{fn (mut value)}}
- />
- </StyleguideExample>
-
- <StyleguideExample
- @title="<ComboBox> with a default state"
- @code={{this.comboBoxDefaultStateCode}}
- @initialValue={{get @dummy "options.0.name"}}
- as |value|
- >
- <ComboBox
- @content={{@dummy.options}}
- @value={{value}}
- @options={{hash none="category.none"}}
- @onChange={{fn (mut value)}}
- />
- </StyleguideExample>
-
- <StyleguideExample
- @title="<ComboBox> clearable"
- @code={{this.comboBoxClearableCode}}
- @initialValue={{get @dummy "options.0.name"}}
- as |value|
- >
- <ComboBox
- @content={{@dummy.options}}
- @clearable={{true}}
- @value={{value}}
- @options={{hash none="category.none"}}
- @onChange={{fn (mut value)}}
- />
- </StyleguideExample>
-
- <StyleguideExample
- @title="<TopicNotificationsTracking>"
- @code={{this.topicNotificationsTrackingCode}}
- @initialValue={{1}}
- as |value|
- >
- <TopicNotificationsTracking
- @levelId={{value}}
- @onChange={{fn (mut value)}}
- />
- </StyleguideExample>
-
- <StyleguideExample
- @title="<CategoryChooser>"
- @code={{this.categoryChooserCode}}
- @initialValue={{get @categories "0" "name"}}
- as |value|
- >
- <CategoryChooser @value={{value}} @onChange={{fn (mut value)}} />
- </StyleguideExample>
-
- <StyleguideExample @title="<PinnedButton>" @code={{this.pinnedButtonCode}}>
- <PinnedButton @topic={{@dummy.pinnedTopic}} @pinned={{true}} />
- </StyleguideExample>
-
- <StyleguideExample
- @title="<PinnedOptions>"
- @code={{this.pinnedOptionsCode}}
- >
- <PinnedOptions @topic={{@dummy.pinnedTopic}} />
- </StyleguideExample>
-
- <StyleguideExample
- @title="<CategoriesAdminDropdown>"
- @code={{this.categoriesAdminDropdownCode}}
- >
- <CategoriesAdminDropdown @onChange={{@dummyAction}} />
- </StyleguideExample>
-
- <StyleguideExample
- @title="<CategoryNotificationsTracking>"
- @code={{this.categoryNotificationsTrackingCode}}
- >
- <CategoryNotificationsTracking
- @levelId={{1}}
- @onChange={{@dummyAction}}
- />
- </StyleguideExample>
-
- <StyleguideExample
- @title="<DropdownSelectBox>"
- @code={{this.dropdownSelectBoxCode}}
- >
- <DropdownSelectBox
- @content={{@dummy.options}}
- @onChange={{@dummyAction}}
- @options={{hash translatedNone="Something"}}
- />
- </StyleguideExample>
-
- <StyleguideExample
- @title="<FutureDateInputSelector>"
- @code={{this.futureDateInputSelectorCode}}
- >
- <FutureDateInputSelector
- @input={{@dummy.topicTimerUpdateDate}}
- @includeWeekend={{true}}
- @includeForever={{true}}
- @options={{hash none="time_shortcut.select_timeframe"}}
- />
- </StyleguideExample>
-
- <StyleguideExample @title="<MultiSelect>" @code={{this.multiSelectCode}}>
- <MultiSelect @content={{@dummy.options}} @onChange={{@dummyAction}} />
- </StyleguideExample>
-
- <StyleguideExample
- @title="<MiniTagChooser>"
- @code={{this.miniTagChooserCode}}
- >
- <div class="inline-form">
- <MiniTagChooser
- @value={{@dummy.selectedTags}}
- @options={{hash filterable=true}}
- />
- </div>
- </StyleguideExample>
-
- <StyleguideExample
- @title="<MiniTagChooser> with useHeaderFilter=true"
- @code={{this.miniTagChooserHeaderFilterCode}}
- >
- <div class="inline-form">
- <MiniTagChooser
- @value={{@dummy.selectedTags}}
- @options={{hash
- filterable=true
- filterPlaceholder="tagging.choose_for_topic"
- useHeaderFilter=true
- }}
- />
- </div>
- </StyleguideExample>
-
- <StyleguideExample
- @title="admin <GroupChooser>"
- @code={{this.groupChooserCode}}
- >
- <GroupChooser
- @selected={{@dummy.selectedGroups}}
- @content={{@dummy.groups}}
- @onChange={{@dummyAction}}
- />
- </StyleguideExample>
-
- <StyleguideExample @title="<ListSetting>" @code={{this.listSettingCode}}>
- <ListSetting
- @settingValue={{@dummy.settings}}
- @onChange={{@dummyAction}}
- />
- </StyleguideExample>
-
- <StyleguideExample
- @title="<ListSetting>"
- @code={{this.listSettingNamePropertyCode}}
- >
- <ListSetting
- @settingValue={{@dummy.colors}}
- @nameProperty="color"
- @onChange={{@dummyAction}}
- />
- </StyleguideExample>
-
- <StyleguideExample
- @title="<UserNotificationsDropdown>"
- @code={{this.userNotificationsDropdownCode}}
- >
- <UserNotificationsDropdown
- @user={{@currentUser}}
- @value="changeToNormal"
- />
- </StyleguideExample>
-
- <StyleguideExample @title="<DIconGridPicker>" @code={{this.iconPickerCode}}>
- <DIconGridPicker />
- </StyleguideExample>
- </template>
-}
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/10-topic-link-status.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/10-topic-link-status.gjs
index 8fe7886e127..176877307bf 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/10-topic-link-status.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/10-topic-link-status.gjs
@@ -1,145 +1,53 @@
-import Component from "@glimmer/component";
-import TopicStatus from "discourse/components/topic-status";
-import dTopicLink from "discourse/ui-kit/helpers/d-topic-link";
import StyleguideExample from "discourse/plugins/styleguide/discourse/components/styleguide-example";
-
-export default class TopicStatuses extends Component {
- get noStatusCode() {
- return `
-import topicLink from "discourse/helpers/topic-link";
-
-<template>
- {{topicLink @dummy.topic}}
-</template>
- `;
- }
-
- get invisibleCode() {
- return `
-import topicLink from "discourse/helpers/topic-link";
-import TopicStatus from "discourse/components/topic-status";
-
-<template>
- <TopicStatus @topic={{@dummy.invisibleTopic}} />
- {{topicLink @dummy.invisibleTopic}}
-</template>
- `;
- }
-
- get closedCode() {
- return `
-import topicLink from "discourse/helpers/topic-link";
-import TopicStatus from "discourse/components/topic-status";
-
-<template>
- <TopicStatus @topic={{@dummy.closedTopic}} />
- {{topicLink @dummy.closedTopic}}
-</template>
- `;
- }
-
- get pinnedCode() {
- return `
-import topicLink from "discourse/helpers/topic-link";
-import TopicStatus from "discourse/components/topic-status";
-
-<template>
- <TopicStatus @topic={{@dummy.pinnedTopic}} />
- {{topicLink @dummy.pinnedTopic}}
-</template>
- `;
- }
-
- get unpinnedCode() {
- return `
-import topicLink from "discourse/helpers/topic-link";
-import TopicStatus from "discourse/components/topic-status";
-
-<template>
- <TopicStatus @topic={{@dummy.unpinnedTopic}} />
- {{topicLink @dummy.unpinnedTopic}}
+import NoStatusExample from "../../examples/atoms/topic-link-status/no-status";
+import noStatusSource from "../../examples/atoms/topic-link-status/no-status?source=file";
+import WithStatusExample from "../../examples/atoms/topic-link-status/with-status";
+import withStatusSource from "../../examples/atoms/topic-link-status/with-status?source=file";
+
+export default <template>
+ <StyleguideExample @title="topic-link (no status)" @code={{noStatusSource}}>
+ <NoStatusExample @topic={{@dummy.topic}} />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="topic-link (status: invisible)"
+ @code={{withStatusSource}}
+ >
+ <WithStatusExample @topic={{@dummy.invisibleTopic}} />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="topic-link (status: closed)"
+ @code={{withStatusSource}}
+ >
+ <WithStatusExample @topic={{@dummy.closedTopic}} />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="topic-link (status: pinned)"
+ @code={{withStatusSource}}
+ >
+ <WithStatusExample @topic={{@dummy.pinnedTopic}} />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="topic-link (status: unpinned)"
+ @code={{withStatusSource}}
+ >
+ <WithStatusExample @topic={{@dummy.unpinnedTopic}} />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="topic-link (status: archived)"
+ @code={{withStatusSource}}
+ >
+ <WithStatusExample @topic={{@dummy.archivedTopic}} />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="topic-link (status: warning)"
+ @code={{withStatusSource}}
+ >
+ <WithStatusExample @topic={{@dummy.warningTopic}} />
+ </StyleguideExample>
</template>
- `;
- }
-
- get archivedCode() {
- return `
-import topicLink from "discourse/helpers/topic-link";
-import TopicStatus from "discourse/components/topic-status";
-
-<template>
- <TopicStatus @topic={{@dummy.archivedTopic}} />
- {{topicLink @dummy.archivedTopic}}
-</template>
- `;
- }
-
- get warningCode() {
- return `
-import topicLink from "discourse/helpers/topic-link";
-import TopicStatus from "discourse/components/topic-status";
-
-<template>
- <TopicStatus @topic={{@dummy.warningTopic}} />
- {{topicLink @dummy.warningTopic}}
-</template>
- `;
- }
-
- <template>
- <StyleguideExample
- @title="topic-link (no status)"
- @code={{this.noStatusCode}}
- >
- {{dTopicLink @dummy.topic}}
- </StyleguideExample>
-
- <StyleguideExample
- @title="topic-link (status: invisible)"
- @code={{this.invisibleCode}}
- >
- <TopicStatus @topic={{@dummy.invisibleTopic}} />
- {{dTopicLink @dummy.invisibleTopic}}
- </StyleguideExample>
-
- <StyleguideExample
- @title="topic-link (status: closed)"
- @code={{this.closedCode}}
- >
- <TopicStatus @topic={{@dummy.closedTopic}} />
- {{dTopicLink @dummy.closedTopic}}
- </StyleguideExample>
-
- <StyleguideExample
- @title="topic-link (status: pinned)"
- @code={{this.pinnedCode}}
- >
- <TopicStatus @topic={{@dummy.pinnedTopic}} />
- {{dTopicLink @dummy.pinnedTopic}}
- </StyleguideExample>
-
- <StyleguideExample
- @title="topic-link (status: unpinned)"
- @code={{this.unpinnedCode}}
- >
- <TopicStatus @topic={{@dummy.unpinnedTopic}} />
- {{dTopicLink @dummy.unpinnedTopic}}
- </StyleguideExample>
-
- <StyleguideExample
- @title="topic-link (status: archived)"
- @code={{this.archivedCode}}
- >
- <TopicStatus @topic={{@dummy.archivedTopic}} />
- {{dTopicLink @dummy.archivedTopic}}
- </StyleguideExample>
-
- <StyleguideExample
- @title="topic-link (status: warning)"
- @code={{this.warningCode}}
- >
- <TopicStatus @topic={{@dummy.warningTopic}} />
- {{dTopicLink @dummy.warningTopic}}
- </StyleguideExample>
- </template>
-}
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/bread-crumbs.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/bread-crumbs.gjs
index f2eded47058..c24af8d941c 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/bread-crumbs.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/bread-crumbs.gjs
@@ -1,24 +1,9 @@
-import Component from "@glimmer/component";
-import BreadCrumbs from "discourse/components/bread-crumbs";
import StyleguideExample from "discourse/plugins/styleguide/discourse/components/styleguide-example";
+import BreadCrumbsExample from "../../examples/molecules/bread-crumbs";
+import breadCrumbsSource from "../../examples/molecules/bread-crumbs?source=file";
-export default class BreadCrumbsMolecule extends Component {
- get categoryBreadcrumbsCode() {
- return `
-import BreadCrumbs from "discourse/components/bread-crumbs";
-
-<template>
- <BreadCrumbs @categories={{@dummy.categories}} @showTags={{false}} />
+export default <template>
+ <StyleguideExample @title="<BreadCrumbs>" @code={{breadCrumbsSource}}>
+ <BreadCrumbsExample @categories={{@dummy.categories}} />
+ </StyleguideExample>
</template>
- `;
- }
-
- <template>
- <StyleguideExample
- @title="<BreadCrumbs>"
- @code={{this.categoryBreadcrumbsCode}}
- >
- <BreadCrumbs @categories={{@dummy.categories}} @showTags={{false}} />
- </StyleguideExample>
- </template>
-}
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/categories.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/categories.gjs
index e4af863620e..7ea14aa1f07 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/categories.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/categories.gjs
@@ -1,17 +1,9 @@
-import Component from "@glimmer/component";
-import dCategoryBadge from "discourse/ui-kit/helpers/d-category-badge";
import StyleguideExample from "discourse/plugins/styleguide/discourse/components/styleguide-example";
+import CategoryBadgeExample from "../../examples/molecules/category-badge";
+import categoryBadgeSource from "../../examples/molecules/category-badge?source=file";
-export default class Categories extends Component {
- categoryBadgeCode = `{{#each @dummy.categories as |c|}}
- {{categoryBadge c categoryStyle="bullet"}}
-{{/each}}`;
-
- <template>
- <StyleguideExample @title="categoryBadge" @code={{this.categoryBadgeCode}}>
- {{#each @dummy.categories as |c|}}
- {{dCategoryBadge c categoryStyle="bullet"}}
- {{/each}}
- </StyleguideExample>
- </template>
-}
+export default <template>
+ <StyleguideExample @title="categoryBadge" @code={{categoryBadgeSource}}>
+ <CategoryBadgeExample @categories={{@dummy.categories}} />
+ </StyleguideExample>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/char-counter.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/char-counter.gjs
index db5cb3804b8..a205241e673 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/char-counter.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/char-counter.gjs
@@ -1,9 +1,9 @@
import StyleguideExample from "discourse/plugins/styleguide/discourse/components/styleguide-example";
-import CharCounterExample from "../../examples/char-counter";
-import charCounterSource from "../../examples/char-counter.gjs?source=file";
+import CharCounterExample from "../../examples/molecules/char-counter";
+import charCounterSource from "../../examples/molecules/char-counter?source=file";
export default <template>
<StyleguideExample @title="<DCharCounter>" @code={{charCounterSource}}>
- <CharCounterExample @dummy={{@dummy}} />
+ <CharCounterExample />
</StyleguideExample>
</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/empty-state.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/empty-state.gjs
index 63631a4b57b..3d791af47ea 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/empty-state.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/empty-state.gjs
@@ -1,13 +1,9 @@
-import Component from "@glimmer/component";
-import DEmptyState from "discourse/ui-kit/d-empty-state";
import StyleguideExample from "discourse/plugins/styleguide/discourse/components/styleguide-example";
+import EmptyStateExample from "../../examples/molecules/empty-state";
+import emptyStateSource from "../../examples/molecules/empty-state?source=file";
-export default class EmptyStateMolecule extends Component {
- emptyStateCode = `<EmptyState @title={{@dummy.sentence}} @body={{@dummy.short_sentence}} />`;
-
- <template>
- <StyleguideExample @title="<EmptyState>" @code={{this.emptyStateCode}}>
- <DEmptyState @title={{@dummy.sentence}} @body={{@dummy.short_sentence}} />
- </StyleguideExample>
- </template>
-}
+export default <template>
+ <StyleguideExample @title="<DEmptyState>" @code={{emptyStateSource}}>
+ <EmptyStateExample />
+ </StyleguideExample>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/menus.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/menus.gjs
index b41e28bed93..feb33a23a3b 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/menus.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/menus.gjs
@@ -38,38 +38,6 @@ export default class Menus extends Component {
this._content = trustHTML(value);
}
- get templateCode() {
- return `<DMenu
- @label={{html-safe "${this.label}"}}
- @content={{html-safe "${this.content}"}}
-/>`;
- }
-
- get templateCodeContent() {
- return `<DMenu @maxWidth={{100}}>
- <:trigger>
- ${this.label}
- </:trigger>
- <:content>
- ${this.content}
- </:content>
-</DMenu>`;
- }
-
- get serviceCode() {
- return `this.menu.register(
- document.queryselector(".my-element"),
- { content: htmlSafe(${this.content}) }
-);`;
- }
-
- get serviceCodeComponent() {
- return `this.menu.register(
- document.queryselector(".my-element"),
- { component: MyComponent, data: { foo: 1 } }
-);`;
- }
-
@action
toggleArrow() {
this.arrow = !this.arrow;
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/multi-select.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/multi-select.gjs
index 51af88946c6..8948377458c 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/multi-select.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/multi-select.gjs
@@ -1,54 +1,14 @@
-import Component from "@glimmer/component";
-import { tracked } from "@glimmer/tracking";
-import { action } from "@ember/object";
-import DMultiSelect from "discourse/ui-kit/d-multi-select";
+import MultiSelectExample from "../../examples/molecules/multi-select";
+import multiSelectSource from "../../examples/molecules/multi-select?source=file";
import StyleguideComponent from "../../styleguide/component";
import StyleguideExample from "../../styleguide-example";
-export default class MultiSelect extends Component {
- @tracked selection = [{ id: 1, name: "foo" }];
-
- multiSelectCode = `<DMultiSelect
- @loadFn={{this.loadDummyData}}
- @onChange={{this.onChange}}
- @selection={{this.selection}}
->
- <:result as |result|>{{result.name}}</:result>
- <:selection as |result|>{{result.name}}</:selection>
-</DMultiSelect>`;
-
- @action
- onChange(selection) {
- this.selection = selection;
- }
-
- @action
- async loadDummyData(filter) {
- await new Promise((resolve) => setTimeout(resolve, 500));
-
- return [
- { id: 1, name: "foo" },
- { id: 2, name: "bar" },
- { id: 3, name: "baz" },
- ].filter((item) => {
- return item.name.toLowerCase().includes(filter.toLowerCase());
- });
- }
-
- <template>
- <StyleguideExample @title="<DMultiSelect />" @code={{this.multiSelectCode}}>
- <StyleguideComponent @tag="d-multi-select component">
- <:sample>
- <DMultiSelect
- @loadFn={{this.loadDummyData}}
- @onChange={{this.onChange}}
- @selection={{this.selection}}
- >
- <:result as |result|>{{result.name}}</:result>
- <:selection as |result|>{{result.name}}</:selection>
- </DMultiSelect>
- </:sample>
- </StyleguideComponent>
- </StyleguideExample>
- </template>
-}
+export default <template>
+ <StyleguideExample @title="<DMultiSelect />" @code={{multiSelectSource}}>
+ <StyleguideComponent @tag="d-multi-select component">
+ <:sample>
+ <MultiSelectExample />
+ </:sample>
+ </StyleguideComponent>
+ </StyleguideExample>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/navigation-bar.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/navigation-bar.gjs
index 449a0597192..d8dd9abb235 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/navigation-bar.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/navigation-bar.gjs
@@ -1,76 +1,27 @@
-import Component from "@glimmer/component";
-import MobileNav from "discourse/components/mobile-nav";
-import NavigationBar from "discourse/components/navigation-bar";
-import GroupDropdown from "discourse/select-kit/components/group-dropdown";
import StyleguideExample from "discourse/plugins/styleguide/discourse/components/styleguide-example";
-
-export default class NavigationBarMolecule extends Component {
- navigationBarCode = `<NavigationBar @navItems={{@dummy.navItems}} @filterMode="latest" />`;
-
- userNavCode = `<MobileNav @desktopClass="nav nav-pills user-nav" class="main-nav">
- {{#each @dummy.navItems as |ni|}}
- <li>
- <a href={{ni.href}} class={{if ni.styleGuideActive "active"}}>
- {{ni.displayName}}
- </a>
- </li>
- {{/each}}
-</MobileNav>`;
-
- groupNavCode = `<MobileNav @desktopClass="nav nav-pills" class="group-nav">
- <li class="group-dropdown">
- <GroupDropdown @groups={{@dummy.groupNames}} @value="staff" />
- </li>
-
- {{#each @dummy.navItems as |ni|}}
- <li>
- <a href={{ni.href}} class={{if ni.styleGuideActive "active"}}>
- {{ni.displayName}}
- </a>
- </li>
- {{/each}}
-</MobileNav>`;
-
- <template>
- <StyleguideExample
- @title="<NavigationBar>"
- @code={{this.navigationBarCode}}
- >
- <NavigationBar @navItems={{@dummy.navItems}} @filterMode="latest" />
- </StyleguideExample>
-
- <StyleguideExample
- @title=".user-main .nav-pills"
- @code={{this.userNavCode}}
- >
- <MobileNav @desktopClass="nav nav-pills user-nav" class="main-nav">
- {{#each @dummy.navItems as |ni|}}
- <li>
- <a href={{ni.href}} class={{if ni.styleGuideActive "active"}}>
- {{ni.displayName}}
- </a>
- </li>
- {{/each}}
- </MobileNav>
- </StyleguideExample>
-
- <StyleguideExample
- @title="group page <NavigationBar>"
- @code={{this.groupNavCode}}
- >
- <MobileNav @desktopClass="nav nav-pills" class="group-nav">
- <li class="group-dropdown">
- <GroupDropdown @groups={{@dummy.groupNames}} @value="staff" />
- </li>
-
- {{#each @dummy.navItems as |ni|}}
- <li>
- <a href={{ni.href}} class={{if ni.styleGuideActive "active"}}>
- {{ni.displayName}}
- </a>
- </li>
- {{/each}}
- </MobileNav>
- </StyleguideExample>
- </template>
-}
+import GroupNavPillsExample from "../../examples/molecules/group-nav-pills";
+import groupNavPillsSource from "../../examples/molecules/group-nav-pills?source=file";
+import NavigationBarExample from "../../examples/molecules/navigation-bar";
+import navigationBarSource from "../../examples/molecules/navigation-bar?source=file";
+import UserNavPillsExample from "../../examples/molecules/user-nav-pills";
+import userNavPillsSource from "../../examples/molecules/user-nav-pills?source=file";
+
+export default <template>
+ <StyleguideExample @title="<NavigationBar>" @code={{navigationBarSource}}>
+ <NavigationBarExample @navItems={{@dummy.navItems}} />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title=".user-main .nav-pills"
+ @code={{userNavPillsSource}}
+ >
+ <UserNavPillsExample @navItems={{@dummy.navItems}} />
+ </StyleguideExample>
+
+ <StyleguideExample
+ @title="group page <NavigationBar>"
+ @code={{groupNavPillsSource}}
+ >
+ <GroupNavPillsExample @navItems={{@dummy.navItems}} />
+ </StyleguideExample>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/navigation-stacked.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/navigation-stacked.gjs
index 48bc1ed365c..3c8a1c37b4f 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/navigation-stacked.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/navigation-stacked.gjs
@@ -1,75 +1,23 @@
-import Component from "@glimmer/component";
-import MobileNav from "discourse/components/mobile-nav";
import StyleguideExample from "discourse/plugins/styleguide/discourse/components/styleguide-example";
+import NavStackedExample from "../../examples/molecules/nav-stacked";
+import navStackedSource from "../../examples/molecules/nav-stacked?source=file";
+import UserNavStackedExample from "../../examples/molecules/user-nav-stacked";
+import userNavStackedSource from "../../examples/molecules/user-nav-stacked?source=file";
-export default class NavigationStacked extends Component {
- navStackedCode = `<MobileNav
- @desktopClass="preferences-list action-list nav-stacked"
- class="preferences-nav"
->
- {{#each @dummy.navItems as |ni|}}
- <li>
- <a href={{ni.href}} class={{if ni.styleGuideActive "active"}}>
- {{ni.displayName}}
- </a>
- </li>
- {{/each}}
-</MobileNav>`;
-
- userNavStackedCode = `<section class="user-navigation">
- <MobileNav
- @desktopClass="preferences-list action-list nav-stacked"
- class="preferences-nav"
+export default <template>
+ <StyleguideExample
+ @title=".nav-stacked"
+ class="half-size"
+ @code={{navStackedSource}}
>
- {{#each @dummy.navItems as |ni|}}
- <li>
- <a href={{ni.href}} class={{if ni.styleGuideActive "active"}}>
- {{ni.displayName}}
- </a>
- </li>
- {{/each}}
- </MobileNav>
-</section>`;
-
- <template>
- <StyleguideExample
- @title=".nav-stacked"
- class="half-size"
- @code={{this.navStackedCode}}
- >
- <MobileNav
- @desktopClass="preferences-list action-list nav-stacked"
- class="preferences-nav"
- >
- {{#each @dummy.navItems as |ni|}}
- <li>
- <a href={{ni.href}} class={{if ni.styleGuideActive "active"}}>
- {{ni.displayName}}
- </a>
- </li>
- {{/each}}
- </MobileNav>
- </StyleguideExample>
+ <NavStackedExample @navItems={{@dummy.navItems}} />
+ </StyleguideExample>
- <StyleguideExample
- @title=".user-navigation .nav-stacked"
- class="half-size"
- @code={{this.userNavStackedCode}}
- >
- <section class="user-navigation">
- <MobileNav
- @desktopClass="preferences-list action-list nav-stacked"
- class="preferences-nav"
- >
- {{#each @dummy.navItems as |ni|}}
- <li>
- <a href={{ni.href}} class={{if ni.styleGuideActive "active"}}>
- {{ni.displayName}}
- </a>
- </li>
- {{/each}}
- </MobileNav>
- </section>
- </StyleguideExample>
- </template>
-}
+ <StyleguideExample
+ @title=".user-navigation .nav-stacked"
+ class="half-size"
+ @code={{userNavStackedSource}}
+ >
+ <UserNavStackedExample @navItems={{@dummy.navItems}} />
+ </StyleguideExample>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/post-menu.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/post-menu.gjs
index 3e761b1f276..b8d3099651c 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/post-menu.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/post-menu.gjs
@@ -1,35 +1,9 @@
-import Component from "@glimmer/component";
-import PostMenu from "discourse/components/post/menu";
import StyleguideExample from "discourse/plugins/styleguide/discourse/components/styleguide-example";
+import PostMenuExample from "../../examples/molecules/post-menu";
+import postMenuSource from "../../examples/molecules/post-menu?source=file";
-export default class CharCounterMolecule extends Component {
- get sampleCode() {
- return `
-import PostMenu from "discourse/components/post/menu";
-
-<template>
- <PostMenu
- @post={{@dummy.transformedPost}}
- @canCreatePost={{true}}
- @showFlags={{true}}
- @showLogin={{true}}
- @showReadIndicator={{true}}
- @toggleLike={{true}}
- />
+export default <template>
+ <StyleguideExample @title="<PostMenu>" @code={{postMenuSource}}>
+ <PostMenuExample @post={{@dummy.transformedPost}} />
+ </StyleguideExample>
</template>
- `;
- }
-
- <template>
- <StyleguideExample @title="<PostMenu>" @code={{this.sampleCode}}>
- <PostMenu
- @post={{@dummy.transformedPost}}
- @canCreatePost={{true}}
- @showFlags={{true}}
- @showLogin={{true}}
- @showReadIndicator={{true}}
- @toggleLike={{true}}
- />
- </StyleguideExample>
- </template>
-}
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/segmented-control.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/segmented-control.gjs
index 4c0bb5bfca4..9705c0a7e2d 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/segmented-control.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/segmented-control.gjs
@@ -1,46 +1,12 @@
-import Component from "@glimmer/component";
-import { tracked } from "@glimmer/tracking";
-import { action } from "@ember/object";
-import DSegmentedControl from "discourse/components/d-segmented-control";
import StyleguideExample from "discourse/plugins/styleguide/discourse/components/styleguide-example";
-
-export default class SegmentedControl extends Component {
- @tracked value1 = "week";
-
- items1 = [
- { value: "day", label: "Day" },
- { value: "week", label: "Week" },
- { value: "month", label: "Month" },
- { value: "year", label: "Year" },
- { value: "all", label: "All" },
- ];
-
- get basicCode() {
- return `import DSegmentedControl from "discourse/components/d-segmented-control";
-
-<template>
- <DSegmentedControl
- @name="time-period"
- @items={{this.items}}
- @value={{this.selected}}
- @onSelect={{this.handleSelect}}
- />
-</template>`;
- }
-
- @action
- onSelect1(value) {
- this.value1 = value;
- }
-
- <template>
- <StyleguideExample @title="<DSegmentedControl>" @code={{this.basicCode}}>
- <DSegmentedControl
- @name="time-period"
- @items={{this.items1}}
- @value={{this.value1}}
- @onSelect={{this.onSelect1}}
- />
- </StyleguideExample>
- </template>
-}
+import SegmentedControlExample from "../../examples/molecules/segmented-control";
+import segmentedControlSource from "../../examples/molecules/segmented-control?source=file";
+
+export default <template>
+ <StyleguideExample
+ @title="<DSegmentedControl>"
+ @code={{segmentedControlSource}}
+ >
+ <SegmentedControlExample />
+ </StyleguideExample>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/signup-cta.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/signup-cta.gjs
index 109d78db8c3..dfd6b789cef 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/signup-cta.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/signup-cta.gjs
@@ -1,13 +1,9 @@
-import Component from "@glimmer/component";
-import SignupCta from "discourse/components/signup-cta";
import StyleguideExample from "discourse/plugins/styleguide/discourse/components/styleguide-example";
+import SignupCtaExample from "../../examples/molecules/signup-cta";
+import signupCtaSource from "../../examples/molecules/signup-cta?source=file";
-export default class SignupCtaMolecule extends Component {
- signupCtaCode = `<SignupCta />`;
-
- <template>
- <StyleguideExample @title="<SignupCta>" @code={{this.signupCtaCode}}>
- <SignupCta />
- </StyleguideExample>
- </template>
-}
+export default <template>
+ <StyleguideExample @title="<SignupCta>" @code={{signupCtaSource}}>
+ <SignupCtaExample />
+ </StyleguideExample>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/tooltips.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/tooltips.gjs
index ffacab8f798..ac3f0a8dd89 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/tooltips.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/tooltips.gjs
@@ -93,6 +93,9 @@ export default class Tooltips extends Component {
};
}
+ // These samples are curated rather than sourced from a module: each bakes in
+ // the current value of the controls panel, so it changes as the reader edits
+ // it and no static module could express it.
get tooltipCode() {
const contentValue = this._content.toString().replace(/"/g, '\\"');
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/topic-list-item.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/topic-list-item.gjs
index 5557d368eea..5fb104e00f5 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/topic-list-item.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/topic-list-item.gjs
@@ -1,85 +1,16 @@
-import Component from "@glimmer/component";
-import HeaderActivityCell from "discourse/components/topic-list/header/activity-cell";
-import HeaderLikesCell from "discourse/components/topic-list/header/likes-cell";
-import HeaderPostersCell from "discourse/components/topic-list/header/posters-cell";
-import HeaderRepliesCell from "discourse/components/topic-list/header/replies-cell";
-import HeaderTopicCell from "discourse/components/topic-list/header/topic-cell";
-import HeaderViewsCell from "discourse/components/topic-list/header/views-cell";
-import Item from "discourse/components/topic-list/item";
-import ItemActivityCell from "discourse/components/topic-list/item/activity-cell";
-import ItemLikesCell from "discourse/components/topic-list/item/likes-cell";
-import ItemPostersCell from "discourse/components/topic-list/item/posters-cell";
-import ItemRepliesCell from "discourse/components/topic-list/item/replies-cell";
-import ItemTopicCell from "discourse/components/topic-list/item/topic-cell";
-import ItemViewsCell from "discourse/components/topic-list/item/views-cell";
-import DAG from "discourse/lib/dag";
-import { applyMutableValueTransformer } from "discourse/lib/transformer";
import StyleguideExample from "discourse/plugins/styleguide/discourse/components/styleguide-example";
-
-export default class TopicList extends Component {
- itemCode = `import Item from "discourse/components/topic-list/item";
-
-// The columns definition is usually provided by the parent component
-// See TopicList for an example
-<template>
- <Item @topic={{@dummy.topic}} @columns={{this.columns}} />
-</template>`;
-
- get columns() {
- const defaultColumns = new DAG({
- // Allow customizations to replace just a header cell or just an item cell
- onReplaceItem(_, newValue, oldValue) {
- newValue.header ??= oldValue.header;
- newValue.item ??= oldValue.item;
- },
- });
-
- defaultColumns.add("topic", {
- header: HeaderTopicCell,
- item: ItemTopicCell,
- });
-
- if (this.args.showPosters) {
- defaultColumns.add("posters", {
- header: HeaderPostersCell,
- item: ItemPostersCell,
- });
- }
-
- defaultColumns.add("replies", {
- header: HeaderRepliesCell,
- item: ItemRepliesCell,
- });
-
- defaultColumns.add("likes", {
- header: HeaderLikesCell,
- item: ItemLikesCell,
- });
-
- defaultColumns.add("views", {
- header: HeaderViewsCell,
- item: ItemViewsCell,
- });
-
- defaultColumns.add("activity", {
- header: HeaderActivityCell,
- item: ItemActivityCell,
- });
-
- return applyMutableValueTransformer(
- "topic-list-columns",
- defaultColumns,
- {}
- ).resolve();
- }
-
- <template>
- <StyleguideExample @title="<TopicListItem>" @code={{this.itemCode}}>
- <table class="topic-list">
- <tbody>
- <Item @topic={{@dummy.topic}} @columns={{this.columns}} />
- </tbody>
- </table>
- </StyleguideExample>
- </template>
-}
+import TopicListItemExample from "../../examples/molecules/topic-list-item";
+import topicListItemSource from "../../examples/molecules/topic-list-item?source=file";
+
+export default <template>
+ <StyleguideExample @title="<TopicListItem>" @code={{topicListItemSource}}>
+ <table class="topic-list">
+ <tbody>
+ <TopicListItemExample
+ @topic={{@dummy.topic}}
+ @showPosters={{@showPosters}}
+ />
+ </tbody>
+ </table>
+ </StyleguideExample>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/topic-notifications.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/topic-notifications.gjs
index 5ffa5b79bc6..241fa6d0b6c 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/topic-notifications.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/topic-notifications.gjs
@@ -1,25 +1,25 @@
-import Component from "@glimmer/component";
-import TopicNotificationsButton from "discourse/select-kit/components/topic-notifications-button";
import StyleguideExample from "discourse/plugins/styleguide/discourse/components/styleguide-example";
+import TopicNotificationsButtonExample from "../../examples/molecules/topic-notifications-button";
+import topicNotificationsButtonSource from "../../examples/molecules/topic-notifications-button?source=file";
-export default class TopicNotifications extends Component {
- expandedCode = `<TopicNotificationsButton @topic={{@dummy.topic}} @expanded={{true}} />`;
+export default <template>
+ <StyleguideExample
+ @title="<TopicNotificationsButton> expanded"
+ @code={{topicNotificationsButtonSource}}
+ >
+ <TopicNotificationsButtonExample
+ @topic={{@dummy.topic}}
+ @expanded={{true}}
+ />
+ </StyleguideExample>
- defaultCode = `<TopicNotificationsButton @topic={{@dummy.topic}} @expanded={{false}} />`;
-
- <template>
- <StyleguideExample
- @title="<TopicNotificationsButton> expanded"
- @code={{this.expandedCode}}
- >
- <TopicNotificationsButton @topic={{@dummy.topic}} @expanded={{true}} />
- </StyleguideExample>
-
- <StyleguideExample
- @title="<TopicNotificationsButton>"
- @code={{this.defaultCode}}
- >
- <TopicNotificationsButton @topic={{@dummy.topic}} @expanded={{false}} />
- </StyleguideExample>
- </template>
-}
+ <StyleguideExample
+ @title="<TopicNotificationsButton>"
+ @code={{topicNotificationsButtonSource}}
+ >
+ <TopicNotificationsButtonExample
+ @topic={{@dummy.topic}}
+ @expanded={{false}}
+ />
+ </StyleguideExample>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/topic-timer-info.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/topic-timer-info.gjs
index c961b4f2084..2de6b66f2b3 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/topic-timer-info.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/topic-timer-info.gjs
@@ -1,16 +1,9 @@
-import Component from "@glimmer/component";
-import TopicTimerInfo from "discourse/components/topic-timer-info";
import StyleguideExample from "discourse/plugins/styleguide/discourse/components/styleguide-example";
+import TopicTimerInfoExample from "../../examples/molecules/topic-timer-info";
+import topicTimerInfoSource from "../../examples/molecules/topic-timer-info?source=file";
-export default class TopicTimerInfoMolecule extends Component {
- topicTimerInfoCode = `<TopicTimerInfo @statusType="reminder" @executeAt={{@dummy.soon}} />`;
-
- <template>
- <StyleguideExample
- @title="<TopicTimerInfo>"
- @code={{this.topicTimerInfoCode}}
- >
- <TopicTimerInfo @statusType="reminder" @executeAt={{@dummy.soon}} />
- </StyleguideExample>
- </template>
-}
+export default <template>
+ <StyleguideExample @title="<TopicTimerInfo>" @code={{topicTimerInfoSource}}>
+ <TopicTimerInfoExample />
+ </StyleguideExample>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/00-post.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/00-post.gjs
index 24899496ff3..3151ba63050 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/00-post.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/00-post.gjs
@@ -1,22 +1,9 @@
-import Component from "@glimmer/component";
-import Post from "discourse/components/post";
import StyleguideExample from "discourse/plugins/styleguide/discourse/components/styleguide-example";
+import PostExample from "../../examples/organisms/post";
+import postSource from "../../examples/organisms/post?source=file";
-export default class PostOrganism extends Component {
- get postCode() {
- return `import Post from "discourse/components/post";
-
-<template>
- <Post @post={{@dummy.postModel}} />
-</template>`;
- }
-
- <template>
- <StyleguideExample @title="<Post>" @code={{this.postCode}}>
- <Post
- @post={{@dummy.postModel.transformedPost}}
- @canCreatePost={{true}}
- />
- </StyleguideExample>
- </template>
-}
+export default <template>
+ <StyleguideExample @title="<Post>" @code={{postSource}}>
+ <PostExample @post={{@dummy.postModel.transformedPost}} />
+ </StyleguideExample>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/01-post-list.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/01-post-list.gjs
index 57607b6e8b9..c61275202ea 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/01-post-list.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/01-post-list.gjs
@@ -1,48 +1,22 @@
-import Component from "@glimmer/component";
-import PostList from "discourse/components/post-list";
import { i18n } from "discourse-i18n";
+import PostListExample from "../../examples/organisms/post-list";
+import postListSource from "../../examples/organisms/post-list?source=file";
+import PostListEmptyExample from "../../examples/organisms/post-list-empty";
+import postListEmptySource from "../../examples/organisms/post-list-empty?source=file";
import StyleguideExample from "../../styleguide-example";
-export default class StyleguidePostList extends Component {
- get emptyPostListCode() {
- return `
-import PostList from "discourse/components/post-list";
+export default <template>
+ <StyleguideExample
+ @title={{i18n "styleguide.sections.post_list.empty_example"}}
+ @code={{postListEmptySource}}
+ >
+ <PostListEmptyExample />
+ </StyleguideExample>
-<template>
- <PostList @posts="" @additionalItemClasses="styleguide-post-list-item" />
+ <StyleguideExample
+ @title={{i18n "styleguide.sections.post_list.populated_example"}}
+ @code={{postListSource}}
+ >
+ <PostListExample @posts={{@dummy.postList}} />
+ </StyleguideExample>
</template>
- `;
- }
-
- get populatedPostListCode() {
- return `
-import PostList from "discourse/components/post-list";
-
-<template>
- <PostList
- @posts={{@dummy.postList}}
- @additionalItemClasses="styleguide-post-list-item"
- />
-</template>
- `;
- }
-
- <template>
- <StyleguideExample
- @title={{i18n "styleguide.sections.post_list.empty_example"}}
- @code={{this.emptyPostListCode}}
- >
- <PostList @posts="" @additionalItemClasses="styleguide-post-list-item" />
- </StyleguideExample>
-
- <StyleguideExample
- @title={{i18n "styleguide.sections.post_list.populated_example"}}
- @code={{this.populatedPostListCode}}
- >
- <PostList
- @posts={{@dummy.postList}}
- @additionalItemClasses="styleguide-post-list-item"
- />
- </StyleguideExample>
- </template>
-}
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/03-topic-map.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/03-topic-map.gjs
index bc228a261b6..c80902e9134 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/03-topic-map.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/03-topic-map.gjs
@@ -1,27 +1,9 @@
-import Component from "@glimmer/component";
-import TopicMap from "discourse/components/topic-map";
import StyleguideExample from "discourse/plugins/styleguide/discourse/components/styleguide-example";
+import TopicMapExample from "../../examples/organisms/topic-map";
+import topicMapSource from "../../examples/organisms/topic-map?source=file";
-export default class TopicMapOrganism extends Component {
- get topicMapCode() {
- return `
-import TopicMap from "discourse/components/topic-map";
-
-<template>
- <TopicMap
- @model={{@dummy.postModel}}
- @topicDetails={{@dummy.postModel.topic.details}}
- />
+export default <template>
+ <StyleguideExample @title="topic-map" @code={{topicMapSource}}>
+ <TopicMapExample @post={{@dummy.postModel}} />
+ </StyleguideExample>
</template>
- `;
- }
-
- <template>
- <StyleguideExample @title="topic-map" @code={{this.topicMapCode}}>
- <TopicMap
- @model={{@dummy.postModel}}
- @topicDetails={{@dummy.postModel.topic.details}}
- />
- </StyleguideExample>
- </template>
-}
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/04-topic-footer-buttons.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/04-topic-footer-buttons.gjs
index 3409d2db847..b8dc7cf33e0 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/04-topic-footer-buttons.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/04-topic-footer-buttons.gjs
@@ -1,56 +1,23 @@
-import Component from "@glimmer/component";
-import TopicFooterButtons from "discourse/components/topic-footer-buttons";
-import DButton from "discourse/ui-kit/d-button";
import StyleguideExample from "discourse/plugins/styleguide/discourse/components/styleguide-example";
+import TopicFooterButtonsExample from "../../examples/organisms/topic-footer-buttons";
+import topicFooterButtonsSource from "../../examples/organisms/topic-footer-buttons?source=file";
+import TopicFooterButtonsAnonymousExample from "../../examples/organisms/topic-footer-buttons-anonymous";
+import topicFooterButtonsAnonymousSource from "../../examples/organisms/topic-footer-buttons-anonymous?source=file";
-export default class TopicFooterButtonsOrganism extends Component {
- get loggedInCode() {
- return `
-import TopicFooterButtons from "discourse/components/topic-footer-buttons";
+export default <template>
+ <StyleguideExample
+ @title="<TopicFooterButtons> - logged in"
+ @code={{topicFooterButtonsSource}}
+ >
+ <TopicFooterButtonsExample @topic={{@dummy.topic}} />
+ </StyleguideExample>
-<template>
- <TopicFooterButtons @topic={{@dummy.topic}} />
+ <StyleguideExample
+ @title="<TopicFooterButtons> - anonymous"
+ @code={{topicFooterButtonsAnonymousSource}}
+ >
+ <div class="styleguide-anon">
+ <TopicFooterButtonsAnonymousExample />
+ </div>
+ </StyleguideExample>
</template>
- `;
- }
-
- get anonymousCode() {
- return `
-import DButton from "discourse/components/d-button";
-
-<template>
- <div id="topic-footer-buttons">
- <DButton
- @icon="reply"
- @label="topic.reply.title"
- class="btn-primary pull-right"
- />
- </div>
-</template>
- `;
- }
-
- <template>
- <StyleguideExample
- @title="<TopicFooterButtons> - logged in"
- @code={{this.loggedInCode}}
- >
- <TopicFooterButtons @topic={{@dummy.topic}} />
- </StyleguideExample>
-
- <StyleguideExample
- @title="<TopicFooterButtons> - anonymous"
- @code={{this.anonymousCode}}
- >
- <div class="styleguide-anon">
- <div id="topic-footer-buttons">
- <DButton
- @icon="reply"
- @label="topic.reply.title"
- class="btn-primary pull-right"
- />
- </div>
- </div>
- </StyleguideExample>
- </template>
-}
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/05-topic-list.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/05-topic-list.gjs
index 4f8904c5d57..752a2c54be7 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/05-topic-list.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/05-topic-list.gjs
@@ -1,38 +1,18 @@
-import Component from "@glimmer/component";
-import TopicList from "discourse/components/topic-list/list";
import StyleguideExample from "discourse/plugins/styleguide/discourse/components/styleguide-example";
+import TopicListExample from "../../examples/organisms/topic-list";
+import topicListSource from "../../examples/organisms/topic-list?source=file";
+import TopicListWithoutPostersExample from "../../examples/organisms/topic-list-without-posters";
+import topicListWithoutPostersSource from "../../examples/organisms/topic-list-without-posters?source=file";
-export default class TopicListOrganism extends Component {
- get topicListCode() {
- return `
-import TopicList from "discourse/components/topic-list/list";
+export default <template>
+ <StyleguideExample @title="<TopicList>" @code={{topicListSource}}>
+ <TopicListExample @topics={{@dummy.topics}} />
+ </StyleguideExample>
-<template>
- <TopicList @topics={{@dummy.topics}} @showPosters={{true}} />
+ <StyleguideExample
+ @title="<TopicList> - hide posters"
+ @code={{topicListWithoutPostersSource}}
+ >
+ <TopicListWithoutPostersExample @topics={{@dummy.topics}} />
+ </StyleguideExample>
</template>
- `;
- }
-
- get topicListHidePostersCode() {
- return `
-import TopicList from "discourse/components/topic-list/list";
-
-<template>
- <TopicList @topics={{@dummy.topics}} @showPosters={{false}} />
-</template>
- `;
- }
-
- <template>
- <StyleguideExample @title="<TopicList>" @code={{this.topicListCode}}>
- <TopicList @topics={{@dummy.topics}} @showPosters={{true}} />
- </StyleguideExample>
-
- <StyleguideExample
- @title="<TopicList> - hide posters>"
- @code={{this.topicListHidePostersCode}}
- >
- <TopicList @topics={{@dummy.topics}} @showPosters={{false}} />
- </StyleguideExample>
- </template>
-}
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/basic-topic-list.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/basic-topic-list.gjs
index 392223e4ae8..0fa687934b3 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/basic-topic-list.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/basic-topic-list.gjs
@@ -1,25 +1,13 @@
-import Component from "@glimmer/component";
-import BasicTopicList from "discourse/components/basic-topic-list";
import StyleguideExample from "discourse/plugins/styleguide/discourse/components/styleguide-example";
+import BasicTopicListExample from "../../examples/organisms/basic-topic-list";
+import basicTopicListSource from "../../examples/organisms/basic-topic-list?source=file";
-export default class BasicTopicListOrganism extends Component {
- get basicTopicListCode() {
- return `
-import BasicTopicList from "discourse/components/basic-topic-list";
-
-<template>
- <BasicTopicList @topics={{@dummy.topics}} />
+export default <template>
+ <StyleguideExample
+ @title="<BasicTopicList>"
+ class="half-size"
+ @code={{basicTopicListSource}}
+ >
+ <BasicTopicListExample @topics={{@dummy.topics}} />
+ </StyleguideExample>
</template>
- `;
- }
-
- <template>
- <StyleguideExample
- @title="<BasicTopicList>"
- class="half-size"
- @code={{this.basicTopicListCode}}
- >
- <BasicTopicList @topics={{@dummy.topics}} />
- </StyleguideExample>
- </template>
-}
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/categories-list.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/categories-list.gjs
index 9a07e0f1cf5..4466a521048 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/categories-list.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/categories-list.gjs
@@ -1,29 +1,9 @@
-import Component from "@glimmer/component";
-import { service } from "@ember/service";
-import CategoriesOnly from "discourse/components/categories-only";
import StyleguideExample from "discourse/plugins/styleguide/discourse/components/styleguide-example";
+import CategoriesOnlyExample from "../../examples/organisms/categories-only";
+import categoriesOnlySource from "../../examples/organisms/categories-only?source=file";
-export default class CategoriesList extends Component {
- @service site;
-
- get categoriesOnlyCode() {
- return `import CategoriesOnly from "discourse/components/categories-only";
-import { service } from "@ember/service";
-export default class CategoriesOnlyExample extends Component {
- @service site;
-
-<template>
- <CategoriesOnly @categories={{this.site.categories}} />
+export default <template>
+ <StyleguideExample @title="<CategoriesOnly>" @code={{categoriesOnlySource}}>
+ <CategoriesOnlyExample />
+ </StyleguideExample>
</template>
-}`;
- }
-
- <template>
- <StyleguideExample
- @title="<CategoriesOnly>"
- @code={{this.categoriesOnlyCode}}
- >
- <CategoriesOnly @categories={{this.site.categories}} />
- </StyleguideExample>
- </template>
-}
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/navigation.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/navigation.gjs
index e1f07a1b14d..a39d545f362 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/navigation.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/navigation.gjs
@@ -1,49 +1,12 @@
-import Component from "@glimmer/component";
-import BreadCrumbs from "discourse/components/bread-crumbs";
-import CreateTopicButton from "discourse/components/create-topic-button";
-import NavigationBar from "discourse/components/navigation-bar";
-import CategoriesAdminDropdown from "discourse/select-kit/components/categories-admin-dropdown";
import StyleguideExample from "discourse/plugins/styleguide/discourse/components/styleguide-example";
-
-export default class Navigation extends Component {
- get navigationCode() {
- return `import BreadCrumbs from "discourse/components/bread-crumbs";
-import CreateTopicButton from "discourse/components/create-topic-button";
-import NavigationBar from "discourse/components/navigation-bar";
-import CategoriesAdminDropdown from "discourse/select-kit/components/categories-admin-dropdown";
-
-<template>
- <div class="list-controls">
- <div class="container">
- <section class="navigation-container">
- <BreadCrumbs @categories={{@dummy.categories}} />
- <NavigationBar @navItems={{@dummy.navItems}} @filterMode="latest" />
-
- <div class="navigation-controls">
- <CategoriesAdminDropdown />
- <CreateTopicButton @canCreateTopic={{true}} />
- </div>
- </section>
- </div>
- </div>
-</template>`;
- }
-
- <template>
- <StyleguideExample @title="navigation" @code={{this.navigationCode}}>
- <div class="list-controls">
- <div class="container">
- <section class="navigation-container">
- <BreadCrumbs @categories={{@dummy.categories}} />
- <NavigationBar @navItems={{@dummy.navItems}} @filterMode="latest" />
-
- <div class="navigation-controls">
- <CategoriesAdminDropdown />
- <CreateTopicButton @canCreateTopic={{true}} />
- </div>
- </section>
- </div>
- </div>
- </StyleguideExample>
- </template>
-}
+import NavigationExample from "../../examples/organisms/navigation";
+import navigationSource from "../../examples/organisms/navigation?source=file";
+
+export default <template>
+ <StyleguideExample @title="navigation" @code={{navigationSource}}>
+ <NavigationExample
+ @categories={{@dummy.categories}}
+ @navItems={{@dummy.navItems}}
+ />
+ </StyleguideExample>
+</template>
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/site-header.gjs b/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/site-header.gjs
index c6f7a660e4c..cea61fa1f98 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/site-header.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/site-header.gjs
@@ -1,6 +1,9 @@
import Component from "@glimmer/component";
import { inject as controller } from "@ember/controller";
-import Header from "discourse/components/header";
+import SiteHeaderExample from "../../examples/organisms/site-header";
+import siteHeaderSource from "../../examples/organisms/site-header?source=file";
+import SiteHeaderInTopicExample from "../../examples/organisms/site-header-in-topic";
+import siteHeaderInTopicSource from "../../examples/organisms/site-header-in-topic?source=file";
import StyleguideExample from "../../styleguide-example";
export default class SiteHeaderStyleguideExample extends Component {
@@ -10,47 +13,19 @@ export default class SiteHeaderStyleguideExample extends Component {
return this.application.sidebarEnabled;
}
- get headerCode() {
- return `import Header from "discourse/components/header";
-
-<template>
- <div inert class="d-header-wrap">
- <Header @sidebarEnabled={{this.sidebarEnabled}} />
- </div>
-</template>`;
- }
-
- get headerInTopicCode() {
- return `import Header from "discourse/components/header";
-
-<template>
- <div inert class="d-header-wrap">
- <Header
- @sidebarEnabled={{this.sidebarEnabled}}
- @topicInfo={{@dummy.topic}}
- @topicInfoVisible={{true}}
- />
- </div>
-</template>`;
- }
-
<template>
- <StyleguideExample @title="site header" @code={{this.headerCode}}>
- <div inert class="d-header-wrap">
- <Header @sidebarEnabled={{this.sidebarEnabled}} />
- </div>
+ <StyleguideExample @title="site header" @code={{siteHeaderSource}}>
+ <SiteHeaderExample @sidebarEnabled={{this.sidebarEnabled}} />
</StyleguideExample>
+
<StyleguideExample
@title="site header - in topic - scrolled"
- @code={{this.headerInTopicCode}}
+ @code={{siteHeaderInTopicSource}}
>
- <div inert class="d-header-wrap">
- <Header
- @sidebarEnabled={{this.sidebarEnabled}}
- @topicInfo={{@dummy.topic}}
- @topicInfoVisible={{true}}
- />
- </div>
+ <SiteHeaderInTopicExample
+ @sidebarEnabled={{this.sidebarEnabled}}
+ @topic={{@dummy.topic}}
+ />
</StyleguideExample>
</template>
}
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/styleguide-example.gjs b/plugins/styleguide/assets/javascripts/discourse/components/styleguide-example.gjs
index 40d13f837af..8e52a9af576 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/styleguide-example.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/styleguide-example.gjs
@@ -1,17 +1,15 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
-import { fn } from "@ember/helper";
-import { not } from "discourse/truth-helpers";
+import { action } from "@ember/object";
import DButton from "discourse/ui-kit/d-button";
import DHighlightedCode from "discourse/ui-kit/d-highlighted-code";
export default class StyleguideExample extends Component {
- @tracked value = null;
@tracked showCode = false;
- constructor() {
- super(...arguments);
- this.value = this.args.initialValue;
+ @action
+ toggleCode() {
+ this.showCode = !this.showCode;
}
<template>
@@ -24,7 +22,7 @@ export default class StyleguideExample extends Component {
{{#if @code}}
<DButton
@icon="code"
- @action={{fn (mut this.showCode) (not this.showCode)}}
+ @action={{this.toggleCode}}
class="btn-flat btn-transparent"
/>
{{/if}}
@@ -36,7 +34,7 @@ export default class StyleguideExample extends Component {
</div>
{{/if}}
- <section class="rendered">{{yield this.value}}</section>
+ <section class="rendered">{{yield}}</section>
</section>
</template>
}
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/styleguide/calendar-date-time-input.gjs b/plugins/styleguide/assets/javascripts/discourse/components/styleguide/calendar-date-time-input.gjs
index c5d4ba35581..1aef243ffb6 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/styleguide/calendar-date-time-input.gjs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/styleguide/calendar-date-time-input.gjs
@@ -2,19 +2,18 @@ import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { Input } from "@ember/component";
import { action } from "@ember/object";
-import DCalendarDateTimeInput from "discourse/ui-kit/d-calendar-date-time-input";
import DDatePicker from "discourse/ui-kit/d-date-picker";
import StyleguideComponent from "discourse/plugins/styleguide/discourse/components/styleguide/component";
import Controls from "discourse/plugins/styleguide/discourse/components/styleguide/controls";
import Row from "discourse/plugins/styleguide/discourse/components/styleguide/controls/row";
import StyleguideExample from "discourse/plugins/styleguide/discourse/components/styleguide-example";
+import CalendarDateTimeInputExample from "../examples/atoms/date-time-inputs/calendar-date-time-input";
+import calendarDateTimeInputSource from "../examples/atoms/date-time-inputs/calendar-date-time-input?source=file";
export default class StyleguideCalendarDateTimeInput extends Component {
@tracked date = null;
@tracked time = null;
@tracked minDate = null;
- dateFormat = "YYYY-MM-DD";
- timeFormat = "HH:mm:ss";
@action
changeDate(date) {
@@ -26,34 +25,16 @@ export default class StyleguideCalendarDateTimeInput extends Component {
this.time = time;
}
- get calendarDateTimeInputCode() {
- return `
-import CalendarDateTimeInput from "discourse/components/calendar-date-time-input";
-
-<template>
- <CalendarDateTimeInput
- @datePickerId="styleguide"
- @date={{this.date}}
- @time={{this.time}}
- @minDate={{this.minDate}}
- />
-</template>
- `;
- }
-
<template>
<StyleguideExample
@title="CalendarDateTimeInput"
- @code={{this.calendarDateTimeInputCode}}
+ @code={{calendarDateTimeInputSource}}
>
<StyleguideComponent>
- <DCalendarDateTimeInput
- @datePickerId="styleguide"
+ <CalendarDateTimeInputExample
@date={{this.date}}
@time={{this.time}}
@minDate={{this.minDate}}
- @timeFormat={{this.timeFormat}}
- @dateFormat={{this.dateFormat}}
@onChangeDate={{this.changeDate}}
@onChangeTime={{this.changeTime}}
/>
diff --git a/plugins/styleguide/assets/javascripts/discourse/lib/dummy-data.js b/plugins/styleguide/assets/javascripts/discourse/lib/dummy-data.js
index 7cbeea56a0e..81f5989f42d 100644
--- a/plugins/styleguide/assets/javascripts/discourse/lib/dummy-data.js
+++ b/plugins/styleguide/assets/javascripts/discourse/lib/dummy-data.js
@@ -240,9 +240,6 @@ export function createData(store) {
warningTopic,
];
- let sentence =
- "Donec viverra lacus id sapien aliquam, tempus tincidunt urna porttitor.";
-
let cooked = `<p>Lorem ipsum dolor sit amet, et nec quis viderer prompta, ex omnium ponderum insolens eos, sed discere invenire principes in. Fuisset constituto per ad. Est no scripta propriae facilisis, viderer impedit deserunt in mel. Quot debet facilisis ne vix, nam in detracto tacimates. At quidam petentium vulputate pro. Alia iudico repudiandae ad vel, erat omnis epicuri eos id. Et illum dolor graeci vel, quo feugiat consulatu ei.</p>
<p>Case everti equidem ius ea, ubique veritus vim id. Eros omnium conclusionemque qui te, usu error alienum imperdiet ut, ex ius meis adipisci. Libris reprehendunt eos ex, mea at nisl suavitate. Altera virtute democritum pro cu, melius latine in ius.</p>`;
@@ -601,29 +598,8 @@ export function createData(store) {
];
_data = {
- options: [
- { id: 1, name: "Orange" },
- { id: 2, name: "Blue" },
- { id: 3, name: "Red" },
- { id: 4, name: "Yellow" },
- ],
-
categories,
- buttonSizes: [
- { class: "btn-large", text: "large" },
- { class: "", text: "default" },
- { class: "btn-small", text: "small" },
- ],
-
- buttonStates: [
- { class: "", text: "normal" },
- { class: "btn-hover", text: "hover" },
- { disabled: true, text: "disabled" },
- ],
-
- toggleSwitchState: true,
-
navItems: ["latest", "categories", "top"].map((name) => {
let item = NavItem.fromText(name);
@@ -647,45 +623,10 @@ export function createData(store) {
topics: bunchOfTopics,
- sentence,
- short_sentence: "Lorem ipsum dolor sit amet.",
- soon: moment().add(2, "days"),
-
transformedPost,
postModel,
postList,
oneboxPosts,
-
- user,
-
- userWithUnread: createUser({
- unread_notifications: 3,
- unread_high_priority_notifications: 7,
- }),
-
- lorem: cooked,
- shortLorem:
- "Lorem ipsum dolor sit amet, et nec quis viderer prompta, ex omnium ponderum insolens eos, sed discere invenire principes in. Fuisset constituto per ad. Est no scripta propriae facilisis, viderer impedit deserunt in mel. Quot debet facilisis ne vix, nam in detracto tacimates. At quidam petentium vulputate pro. Alia iudico repudiandae ad vel, erat omnis epicuri eos id. Et illum dolor graeci vel, quo feugiat consulatu ei.",
-
- topicTimerUpdateDate: "2017-10-18 18:00",
-
- groups: [
- { name: "staff", id: 1, automatic: false },
- { name: "lounge", id: 2, automatic: true },
- { name: "admin", id: 3, automatic: false },
- ],
-
- groupNames: ["staff", "lounge", "admin"],
-
- selectedGroups: [1, 2],
-
- settings: "bold|italic|strike|underline",
-
- colors: "f49|c89|564897",
-
- charCounterContent: "",
-
- selectedTags: ["apple", "orange", "potato"],
};
return _data;