diff --git a/demo/partials/avatar.html b/demo/partials/avatar.html index dd0e42e..c6455c1 100644 --- a/demo/partials/avatar.html +++ b/demo/partials/avatar.html @@ -1,4 +1,4 @@ -
+

Avatar

Sizes

@@ -34,4 +34,22 @@ VL AW + +

Vue avatar

+
+
diff --git a/demo/partials/chips.html b/demo/partials/chips.html index bdc47dc..d5aee5e 100644 --- a/demo/partials/chips.html +++ b/demo/partials/chips.html @@ -1,4 +1,4 @@ -
+

Chips

Default chips

@@ -21,4 +21,31 @@ Small Tiny + +

Vue chips

+
+
diff --git a/demo/partials/choices.html b/demo/partials/choices.html index 088e718..81f2ccc 100644 --- a/demo/partials/choices.html +++ b/demo/partials/choices.html @@ -64,4 +64,28 @@ Disabled on + +

Vue controls

+
+
diff --git a/demo/partials/divider.html b/demo/partials/divider.html index 7bfea68..8a57c53 100644 --- a/demo/partials/divider.html +++ b/demo/partials/divider.html @@ -11,4 +11,22 @@ Before
After + +

Vue divider

+
+
diff --git a/demo/partials/loader.html b/demo/partials/loader.html index 6072611..187db6d 100644 --- a/demo/partials/loader.html +++ b/demo/partials/loader.html @@ -17,4 +17,22 @@ Saving changes... + +

Vue loader

+
+ diff --git a/demo/partials/pagination.html b/demo/partials/pagination.html index 1dea582..6840c6c 100644 --- a/demo/partials/pagination.html +++ b/demo/partials/pagination.html @@ -10,4 +10,22 @@ + +

Vue pagination

+
+ diff --git a/demo/partials/select-textarea.html b/demo/partials/select-textarea.html index 9d6f7ca..1b85bdd 100644 --- a/demo/partials/select-textarea.html +++ b/demo/partials/select-textarea.html @@ -35,4 +35,31 @@ + +

Vue select & textarea

+
+ diff --git a/demo/partials/stepper.html b/demo/partials/stepper.html index e7cde95..867d080 100644 --- a/demo/partials/stepper.html +++ b/demo/partials/stepper.html @@ -41,4 +41,26 @@

Done

+

Vue steps

+
+ diff --git a/src/vue/components/GnDivider.js b/src/vue/components/GnDivider.js new file mode 100644 index 0000000..b431d26 --- /dev/null +++ b/src/vue/components/GnDivider.js @@ -0,0 +1,28 @@ +/** + * GnDivider - Horizontal or vertical divider. + * Keeps API compatible with gnexus-ui-kit. + */ + +import { defineComponent, h } from "vue"; +import { cx } from "../utils.js"; + +export default defineComponent({ + name: "GnDivider", + props: { + orientation: { type: String, default: "horizontal" }, + variant: { type: String, default: "default" }, + dashed: { type: Boolean, default: false } + }, + setup(props, { slots }) { + return () => h("hr", { + class: cx("divider", { + "divider-strong": props.variant === "strong", + "divider-dashed": props.dashed, + "divider-vertical": props.orientation === "vertical" + }), + "data-variant": props.variant !== "default" ? props.variant : undefined, + "data-orientation": props.orientation !== "horizontal" ? props.orientation : undefined, + "aria-hidden": "true" + }, slots.default?.()); + } +}); diff --git a/src/vue/components/GnStep.js b/src/vue/components/GnStep.js new file mode 100644 index 0000000..c3bc7ac --- /dev/null +++ b/src/vue/components/GnStep.js @@ -0,0 +1,38 @@ +/** + * GnStep - Single step for use inside GnSteps. + * Keeps API compatible with gnexus-ui-kit. + */ + +import { defineComponent, h } from "vue"; +import { cx, iconNode } from "../utils.js"; + +export default defineComponent({ + name: "GnStep", + props: { + title: { type: String, default: "" }, + text: { type: String, default: "" }, + marker: { type: [String, Number], default: "" }, + status: { type: String, default: "" }, + disabled: { type: Boolean, default: false } + }, + setup(props, { slots }) { + const isComplete = () => props.status === "complete"; + const resolvedMarker = () => { + if(slots.marker) return slots.marker(); + if(props.marker) return props.marker; + return isComplete() ? iconNode("ph-check") : ""; + }; + + return () => h("li", { + class: cx("step", { + "step-complete": isComplete(), + "step-current": props.status === "current", + "step-disabled": props.disabled || props.status === "disabled" + }) + }, [ + h("span", { class: "step-marker" }, resolvedMarker()), + h("h3", { class: "step-title" }, slots.title?.() || props.title), + (props.text || slots.text) && h("p", { class: "step-text" }, slots.text?.() || props.text) + ]); + } +}); diff --git a/src/vue/components/GnSteps.js b/src/vue/components/GnSteps.js index 0d2403d..81c89db 100644 --- a/src/vue/components/GnSteps.js +++ b/src/vue/components/GnSteps.js @@ -4,7 +4,7 @@ */ import { defineComponent, h } from "vue"; -import { cx } from "../utils.js"; +import { cx, iconNode } from "../utils.js"; export default defineComponent({ name: "GnSteps", @@ -17,16 +17,21 @@ return () => h("ol", { ...attrs, class: cx("steps", { "steps-vertical": props.vertical }, attrs.class) - }, props.items.map((item, index) => h("li", { + }, props.items.map((item, index) => { + const isComplete = item.status === "complete"; + const marker = item.marker || (isComplete ? iconNode("ph-check") : String(index + 1)); + + return h("li", { class: cx("step", { - "step-complete": item.status === "complete", + "step-complete": isComplete, "step-current": item.status === "current", "step-disabled": item.disabled || item.status === "disabled" }) }, [ - h("span", { class: "step-marker" }, item.marker || String(index + 1)), + h("span", { class: "step-marker" }, marker), h("h3", { class: "step-title" }, item.title), item.text && h("p", { class: "step-text" }, item.text) - ]))); + ]); + })); } }); diff --git a/src/vue/index.js b/src/vue/index.js index 2e8a52b..e48491d 100644 --- a/src/vue/index.js +++ b/src/vue/index.js @@ -46,6 +46,8 @@ export { default as GnBreadcrumbItem } from "./components/GnBreadcrumbItem.js"; export { default as GnAccordion } from "./components/GnAccordion.js"; export { default as GnSteps } from "./components/GnSteps.js"; +export { default as GnStep } from "./components/GnStep.js"; +export { default as GnDivider } from "./components/GnDivider.js"; export { default as GnFileUpload } from "./components/GnFileUpload.js"; export { default as GnFileAttachment } from "./components/GnFileAttachment.js"; export { default as GnPopover } from "./components/GnPopover.js"; diff --git a/src/vue/plugin.js b/src/vue/plugin.js index 3310246..612a357 100644 --- a/src/vue/plugin.js +++ b/src/vue/plugin.js @@ -46,6 +46,8 @@ import GnBreadcrumbItem from "./components/GnBreadcrumbItem.js"; import GnAccordion from "./components/GnAccordion.js"; import GnSteps from "./components/GnSteps.js"; +import GnStep from "./components/GnStep.js"; +import GnDivider from "./components/GnDivider.js"; import GnFileUpload from "./components/GnFileUpload.js"; import GnFileAttachment from "./components/GnFileAttachment.js"; import GnPopover from "./components/GnPopover.js"; @@ -97,6 +99,8 @@ GnBreadcrumbItem, GnAccordion, GnSteps, + GnStep, + GnDivider, GnFileUpload, GnFileAttachment, GnPopover, diff --git a/tests/demo-screenshot.spec.js b/tests/demo-screenshot.spec.js index 7496a0c..46010c6 100644 --- a/tests/demo-screenshot.spec.js +++ b/tests/demo-screenshot.spec.js @@ -31,7 +31,15 @@ { name: "timeline", label: "Timeline" }, { name: "drawer", label: "Drawers" }, { name: "toasts", label: "Toasts" }, - { name: "breadcrumbs", label: "Breadcrumbs" } + { name: "breadcrumbs", label: "Breadcrumbs" }, + { name: "choices", label: "Choice controls" }, + { name: "select-textarea", label: "Select & Textarea" }, + { name: "divider", label: "Divider" }, + { name: "stepper", label: "Stepper" }, + { name: "pagination", label: "Pagination" }, + { name: "loader", label: "Loader" }, + { name: "chips", label: "Chips" }, + { name: "avatar", label: "Avatar" } ]; test.describe("@screenshot", () => {