A platform for community discussion. Free, open, simple.
DEV: implements a <DOTP /> component (#35149)
Joffrey JAFFEUX57173bf961ff
diff --git a/app/assets/stylesheets/common/base/login.scss b/app/assets/stylesheets/common/base/login.scssindex 4886bcdf398..921a01f2836 100644--- a/app/assets/stylesheets/common/base/login.scss+++ b/app/assets/stylesheets/common/base/login.scss@@ -43,13 +43,6 @@ body.invite-page {flex-direction: column;width: 400px;- input {- padding: 0.75em 0.77em;- min-width: 250px;- margin-bottom: 0.25em;- width: 100%;- }-.input {position: relative;margin-bottom: 1em;diff --git a/app/assets/stylesheets/common/components/_index.scss b/app/assets/stylesheets/common/components/_index.scssindex 359f4075e40..989163f8eea 100644--- a/app/assets/stylesheets/common/components/_index.scss+++ b/app/assets/stylesheets/common/components/_index.scss@@ -74,3 +74,4 @@@import "dropdown-menu";@import "welcome-banner";@import "d-multi-select";+@import "d-otp";diff --git a/app/assets/stylesheets/common/components/d-otp.scss b/app/assets/stylesheets/common/components/d-otp.scssnew file mode 100644index 00000000000..5ab74f8ada9--- /dev/null+++ b/app/assets/stylesheets/common/components/d-otp.scss@@ -0,0 +1,87 @@+.d-otp {+ display: flex;+ align-items: center;+ position: relative;+}++.d-otp-group {+ display: flex;+ align-items: center;+ gap: 0.5rem;+}++.d-otp-slot {+ padding: 0.5em 0.65em;+ line-height: normal;+ display: flex;+ align-items: center;+ justify-content: center;+ border: var(--d-input-border);+ border-radius: var(--d-border-radius);+ position: relative;+ transition: all 0.3s ease-out;+ width: 1em;++ &.--is-focused {+ @include default-focus;+ }++ &.--show-cursor {+ // fake input blinking cursor+ &::after {+ content: "";+ position: absolute;+ left: 50%;+ top: 50%;+ transform: translateX(-50%) translateY(-50%);+ width: 1px;+ height: 50%;+ background-color: currentcolor;+ animation: otp-cursor-blink 1s infinite;+ }+ }++ &.--placeholder {+ font-size: var(--font-up-0);+ }+}++.d-otp-input-wrapper {+ position: absolute;+ inset: 0;+ pointer-events: none;+}++.d-otp-input {+ position: absolute;+ inset: 0;+ width: 100%;+ height: 100%;+ display: flex;+ text-align: left;+ opacity: 1;+ color: transparent;+ pointer-events: all;+ background: transparent;+ caret-color: transparent;+ border: 0 solid transparent;+ outline: transparent solid 0;+ box-shadow: none;+ line-height: 1;+ letter-spacing: -0.5em;+ font-size: var(--root-height);+ font-family: monospace;+ font-variant-numeric: tabular-nums;+}++@keyframes otp-cursor-blink {+ 0%,+ 50% {+ opacity: 1;+ }++ 51%,+ 100% {+ opacity: 0;+ }+}diff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex 38042cde536..543aed7b7f9 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -2445,6 +2445,10 @@ en:no_results: "No results"search: "Search…"label: "Select options"+ d_otp:+ screen_reader:+ one: Enter a number+ other: Enter %{count} numbersform_kit:reset: Resetoptional: optionaldiff --git a/frontend/discourse/app/components/d-otp/index.gjs b/frontend/discourse/app/components/d-otp/index.gjsnew file mode 100644index 00000000000..5d85473fd0e--- /dev/null+++ b/frontend/discourse/app/components/d-otp/index.gjs@@ -0,0 +1,151 @@+import Component from "@glimmer/component";+import { tracked } from "@glimmer/tracking";+import { on } from "@ember/modifier";+import { action } from "@ember/object";+import { isBlank } from "@ember/utils";+import { TrackedArray } from "@ember-compat/tracked-built-ins";+import preventScrollOnFocus from "discourse/modifiers/prevent-scroll-on-focus";+import { i18n } from "discourse-i18n";+import Slot from "./slot";++const DEFAULT_SLOTS = 6;++export default class DOTP extends Component {+ @tracked isFocused = false;+ @tracked isAllSelected = false;++ otp = new TrackedArray(Array(this.slots).fill(""));++ get slots() {+ return this.args.slots ?? DEFAULT_SLOTS;+ }++ get isFilled() {+ return this.otp.every((char) => !isBlank(char));+ }++ get value() {+ return this.otp.join("");+ }++ @action+ onInput(event) {+ const chars = event.target.value.split("");+ const wasFilled = this.isFilled;++ if (wasFilled && chars.length >= this.otp.length) {+ return;+ }++ for (let i = 0; i < this.otp.length; i++) {+ this.otp[i] = chars[i] || "";+ }++ const joinedOtp = this.otp.join("");++ this.args.onChange?.(joinedOtp);++ // Check if just became filled and call callback+ if (!wasFilled && this.isFilled) {+ this.args.onFill?.(joinedOtp);+ }++ this.isAllSelected = false;+ }++ @action+ onSelect(event) {+ const input = event.target;+ const hasSelection = input.selectionStart !== input.selectionEnd;+ this.isAllSelected =+ hasSelection &&+ input.selectionStart === 0 &&+ input.selectionEnd === input.value.length;+ }++ @action+ onFocus() {+ this.isFocused = true;+ this.isAllSelected = false;+ }++ @action+ onBlur() {+ this.isFocused = false;+ this.isAllSelected = false;+ }++ @action+ onKeyDown(event) {+ // Disable arrow keys as you can only fill last unfilled or backspace+ if (+ ["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(event.key)+ ) {+ event.preventDefault();+ }+ }++ @action+ onPaste(event) {+ const input = event.target;+ event.preventDefault(); // Prevent the call to input as we manually call it later++ const clipboardData = event.clipboardData || window.clipboardData;+ if (!clipboardData) {+ return;+ }++ const pastedData = clipboardData.getData("text");+ input.value = pastedData.replace(/[^0-9]/g, "");+ this.onInput({ target: input });+ }++ @action+ isFocusedSlot(index) {+ if (!this.isFocused) {+ return false;+ }++ if (this.isAllSelected) {+ return !isBlank(this.otp[index]);+ }++ const firstEmptyIndex = this.otp.findIndex((char) => isBlank(char));+ return (+ index === (firstEmptyIndex >= 0 ? firstEmptyIndex : this.otp.length - 1)+ );+ }++ <template>+ <div class="d-otp">+ <div class="d-otp-group">+ {{#each this.otp as |char index|}}+ <Slot+ @index={{index}}+ @char={{char}}+ @isFocused={{this.isFocusedSlot index}}+ />+ {{/each}}+ </div>++ <div class="d-otp-input-wrapper">+ <input+ {{preventScrollOnFocus}}+ inputmode="numeric"+ autocomplete="one-time-code"+ data-slot="input-otp"+ class="d-otp-input"+ maxlength={{this.slots}}+ {{on "input" this.onInput}}+ {{on "select" this.onSelect}}+ {{on "keydown" this.onKeyDown}}+ {{on "focus" this.onFocus}}+ {{on "blur" this.onBlur}}+ {{on "paste" this.onPaste}}+ aria-label={{i18n "d_otp.screen_reader" count=this.slots}}+ ...attributes+ />+ </div>+ </div>+ </template>+}diff --git a/frontend/discourse/app/components/d-otp/slot.gjs b/frontend/discourse/app/components/d-otp/slot.gjsnew file mode 100644index 00000000000..4d9a5502a57--- /dev/null+++ b/frontend/discourse/app/components/d-otp/slot.gjs@@ -0,0 +1,44 @@+import Component from "@glimmer/component";+import { isBlank } from "@ember/utils";+import concatClass from "discourse/helpers/concat-class";++const PLACEHOLDER_CHAR = "-";++export default class Slot extends Component {+ get showCursor() {+ return this.args.isFocused && isBlank(this.args.char);+ }++ get displayChar() {+ if (!isBlank(this.args.char)) {+ return this.args.char;+ }++ if (this.showCursor) {+ return "";+ }++ return PLACEHOLDER_CHAR;+ }++ get isPlaceholder() {+ return this.displayChar === PLACEHOLDER_CHAR;+ }++ <template>+ <div+ class={{concatClass+ "d-otp-slot"+ (if @isFocused "--is-focused")+ (if this.showCursor "--show-cursor")+ (if this.isPlaceholder "--placeholder")+ }}+ data-index={{@index}}+ >+ <span aria-hidden="true">+ ​+ </span>+ {{this.displayChar}}+ </div>+ </template>+}diff --git a/frontend/discourse/app/components/local-login-form.gjs b/frontend/discourse/app/components/local-login-form.gjsindex b705d393fa5..37df95fc43e 100644--- a/frontend/discourse/app/components/local-login-form.gjs+++ b/frontend/discourse/app/components/local-login-form.gjs@@ -16,7 +16,6 @@ import SecurityKeyForm from "discourse/components/security-key-form";import TogglePasswordMask from "discourse/components/toggle-password-mask";import icon from "discourse/helpers/d-icon";import valueEntered from "discourse/helpers/value-entered";-import withEventValue from "discourse/helpers/with-event-value";import { ajax } from "discourse/lib/ajax";import { popupAjaxError } from "discourse/lib/ajax-error";import { escapeExpression } from "discourse/lib/utilities";@@ -259,8 +258,8 @@ export default class LocalLoginForm extends Component {{{else}}<SecondFactorInput{{on "keydown" this.loginOnEnter}}- {{on "input" (withEventValue (fn (mut @secondFactorToken)))}}{{on "focusin" this.scrollInputIntoView}}+ @onChange={{fn (mut @secondFactorToken)}}@secondFactorMethod={{@secondFactorMethod}}value={{@secondFactorToken}}id="login-second-factor"diff --git a/frontend/discourse/app/components/modal/second-factor-add-totp.gjs b/frontend/discourse/app/components/modal/second-factor-add-totp.gjsindex e4fc62fd759..ef7ede8770a 100644--- a/frontend/discourse/app/components/modal/second-factor-add-totp.gjs+++ b/frontend/discourse/app/components/modal/second-factor-add-totp.gjs@@ -166,13 +166,9 @@ export default class SecondFactorAddTotp extends Component {</label><div class="controls totp-app-token"><SecondFactorInput- {{on- "input"- (withEventValue (fn (mut this.secondFactorToken)))- }}+ @onChange={{fn (mut this.secondFactorToken)}}@secondFactorMethod={{this.totpType}}value={{this.secondFactorToken}}- placeholder="123456"id="second-factor-token"/></div>diff --git a/frontend/discourse/app/components/second-factor-input.gjs b/frontend/discourse/app/components/second-factor-input.gjsindex c8af95da8e0..63c36e680ee 100644--- a/frontend/discourse/app/components/second-factor-input.gjs+++ b/frontend/discourse/app/components/second-factor-input.gjs@@ -1,56 +1,36 @@import Component from "@glimmer/component";-import didInsert from "@ember/render-modifiers/modifiers/did-insert";+import { on } from "@ember/modifier";+import DOTP from "discourse/components/d-otp";+import withEventValue from "discourse/helpers/with-event-value";import { SECOND_FACTOR_METHODS } from "discourse/models/user";+import autoFocus from "discourse/modifiers/auto-focus";export default class SecondFactorInput extends Component {- _focusInput(input) {- input.focus();- }-get isTotp() {return this.args.secondFactorMethod === SECOND_FACTOR_METHODS.TOTP;}- get isBackupCode() {- return this.args.secondFactorMethod === SECOND_FACTOR_METHODS.BACKUP_CODE;- }-- get type() {- if (this.isTotp) {- return "tel";- } else if (this.isBackupCode) {- return "text";- }- }-- get pattern() {- if (this.isTotp) {- return "[0-9]{6}";- } else if (this.isBackupCode) {- return "[a-z0-9]{16}";- }- }-- get maxlength() {- if (this.isTotp) {- return "6";- } else if (this.isBackupCode) {- return "32";- }- }-<template>- <input- type={{this.type}}- pattern={{this.pattern}}- maxlength={{this.maxlength}}- autocomplete="one-time-code"- autocapitalize="off"- autocorrect="off"- autofocus="autofocus"- class="second-factor-token-input"- ...attributes- {{didInsert this._focusInput}}- />+ {{#if this.isTotp}}+ <DOTP+ @onFill={{@onFill}}+ @onChange={{@onChange}}+ class="second-factor-token-input"+ ...attributes+ />+ {{else}}+ <input+ type="text"+ pattern="[a-z0-9]{16}"+ maxlength="32"+ autocapitalize="off"+ autocorrect="off"+ autofocus="autofocus"+ class="second-factor-token-input"+ ...attributes+ {{on "input" (withEventValue @onChange)}}+ {{autoFocus}}+ />+ {{/if}}</template>}diff --git a/frontend/discourse/app/templates/email-login.gjs b/frontend/discourse/app/templates/email-login.gjsindex 620bc1c9978..696714a096f 100644--- a/frontend/discourse/app/templates/email-login.gjs+++ b/frontend/discourse/app/templates/email-login.gjs@@ -1,11 +1,9 @@import { fn } from "@ember/helper";-import { on } from "@ember/modifier";import { htmlSafe } from "@ember/template";import DButton from "discourse/components/d-button";import SecondFactorForm from "discourse/components/second-factor-form";import SecondFactorInput from "discourse/components/second-factor-input";import SecurityKeyForm from "discourse/components/security-key-form";-import withEventValue from "discourse/helpers/with-event-value";import { i18n } from "discourse-i18n";export default <template>@@ -47,10 +45,7 @@ export default <template>@isLogin={{true}}><SecondFactorInput- {{on- "input"- (withEventValue (fn (mut @controller.secondFactorToken)))- }}+ @onChange={{fn (mut @controller.secondFactorToken)}}@secondFactorMethod={{@controller.secondFactorMethod}}value={{@controller.secondFactorToken}}/>diff --git a/frontend/discourse/app/templates/password-reset.gjs b/frontend/discourse/app/templates/password-reset.gjsindex ad53c96883d..2768d620f76 100644--- a/frontend/discourse/app/templates/password-reset.gjs+++ b/frontend/discourse/app/templates/password-reset.gjs@@ -11,7 +11,6 @@ import bodyClass from "discourse/helpers/body-class";import icon from "discourse/helpers/d-icon";import hideApplicationHeaderButtons from "discourse/helpers/hide-application-header-buttons";import hideApplicationSidebar from "discourse/helpers/hide-application-sidebar";-import withEventValue from "discourse/helpers/with-event-value";import { i18n } from "discourse-i18n";export default <template>@@ -64,10 +63,7 @@ export default <template>@isLogin={{false}}><SecondFactorInput- {{on- "input"- (withEventValue (fn (mut @controller.secondFactorToken)))- }}+ @onChange={{fn (mut @controller.secondFactorToken)}}@secondFactorMethod={{@controller.selectedSecondFactorMethod}}value={{@controller.secondFactorToken}}id="second-factor"diff --git a/frontend/discourse/app/templates/second-factor-auth.gjs b/frontend/discourse/app/templates/second-factor-auth.gjsindex 4a0ee9e9c1c..fc4e1e26aad 100644--- a/frontend/discourse/app/templates/second-factor-auth.gjs+++ b/frontend/discourse/app/templates/second-factor-auth.gjs@@ -4,7 +4,6 @@ import { gt, not, or } from "truth-helpers";import DButton from "discourse/components/d-button";import SecondFactorInput from "discourse/components/second-factor-input";import hideApplicationSidebar from "discourse/helpers/hide-application-sidebar";-import withEventValue from "discourse/helpers/with-event-value";import { i18n } from "discourse-i18n";export default <template>@@ -32,10 +31,7 @@ export default <template>{{else if (or @controller.showTotpForm @controller.showBackupCodesForm)}}<form class={{@controller.inputFormClass}}><SecondFactorInput- {{on- "input"- (withEventValue (fn (mut @controller.secondFactorToken)))- }}+ @onChange={{fn (mut @controller.secondFactorToken)}}@secondFactorMethod={{@controller.shownSecondFactorMethod}}value={{@controller.secondFactorToken}}/>diff --git a/frontend/discourse/tests/integration/components/d-otp-test.gjs b/frontend/discourse/tests/integration/components/d-otp-test.gjsnew file mode 100644index 00000000000..53fa1922154--- /dev/null+++ b/frontend/discourse/tests/integration/components/d-otp-test.gjs@@ -0,0 +1,166 @@+import { next } from "@ember/runloop";+import { render, settled } from "@ember/test-helpers";+import { module, test } from "qunit";+import DOTP from "discourse/components/d-otp";+import { setupRenderingTest } from "discourse/tests/helpers/component-test";++module("Integration | Component | DOTP", function (hooks) {+ setupRenderingTest(hooks);++ test("renders 6 slots by default", async function (assert) {+ await render(<template><DOTP /></template>);++ assert.dom(".d-otp-slot").exists({ count: 6 });+ });++ test("renders custom number of slots", async function (assert) {+ await render(<template><DOTP @slots={{8}} /></template>);++ assert.dom(".d-otp-slot").exists({ count: 8 });+ });++ test("accepts input and fills slots", async function (assert) {+ await render(<template><DOTP /></template>);++ const input = this.element.querySelector(".d-otp-input");+ input.value = "123456";+ input.dispatchEvent(new Event("input"));++ await settled();++ assert.dom(".d-otp-slot:nth-child(1)").hasText(" 1");+ assert.dom(".d-otp-slot:nth-child(2)").hasText(" 2");+ assert.dom(".d-otp-slot:nth-child(3)").hasText(" 3");+ assert.dom(".d-otp-slot:nth-child(4)").hasText(" 4");+ assert.dom(".d-otp-slot:nth-child(5)").hasText(" 5");+ assert.dom(".d-otp-slot:nth-child(6)").hasText(" 6");+ });++ test("calls onFill when all slots are filled", async function (assert) {+ this.set("filledValue", null);+ this.onFillCallback = (value) => {+ this.set("filledValue", value);+ };++ await render(<template><DOTP @onFill={{this.onFillCallback}} /></template>);++ const input = this.element.querySelector(".d-otp-input");+ input.value = "123456";+ input.dispatchEvent(new Event("input"));++ await new Promise((resolve) => next(resolve));++ assert.strictEqual(this.filledValue, "123456");+ });++ test("calls onChange when filling slots", async function (assert) {+ this.set("value", null);++ this.onChangeCallback = (value) => {+ this.set("value", value);+ };++ await render(+ <template><DOTP @onChange={{this.onChangeCallback}} /></template>+ );++ const input = this.element.querySelector(".d-otp-input");+ input.value = "1";+ input.dispatchEvent(new Event("input"));++ await new Promise((resolve) => next(resolve));++ assert.strictEqual(this.value, "1");++ input.value = "12";+ input.dispatchEvent(new Event("input"));++ await new Promise((resolve) => next(resolve));++ assert.strictEqual(this.value, "12");+ });++ test("shows placeholder dashes for empty slots", async function (assert) {+ await render(<template><DOTP /></template>);++ assert.dom(".d-otp-slot:nth-child(1)").hasText(" -");+ assert.dom(".d-otp-slot:nth-child(2)").hasText(" -");+ assert.dom(".d-otp-slot:nth-child(3)").hasText(" -");+ assert.dom(".d-otp-slot:nth-child(4)").hasText(" -");+ assert.dom(".d-otp-slot:nth-child(5)").hasText(" -");+ assert.dom(".d-otp-slot:nth-child(6)").hasText(" -");+ });++ test("handles paste with spaces correctly", async function (assert) {+ await render(<template><DOTP /></template>);++ const input = this.element.querySelector(".d-otp-input");++ const pasteEvent = new Event("paste");+ pasteEvent.clipboardData = {+ getData: () => "1 2 3 4 5 6",+ };++ input.dispatchEvent(pasteEvent);++ await settled();++ assert.dom(".d-otp-slot:nth-child(1)").hasText(" 1");+ assert.dom(".d-otp-slot:nth-child(2)").hasText(" 2");+ assert.dom(".d-otp-slot:nth-child(3)").hasText(" 3");+ assert.dom(".d-otp-slot:nth-child(4)").hasText(" 4");+ assert.dom(".d-otp-slot:nth-child(5)").hasText(" 5");+ assert.dom(".d-otp-slot:nth-child(6)").hasText(" 6");+ });++ test("removes non-digit characters from paste", async function (assert) {+ await render(<template><DOTP /></template>);++ const input = this.element.querySelector(".d-otp-input");++ const pasteEvent = new Event("paste", { bubbles: true });+ pasteEvent.clipboardData = {+ getData: () => "a1-2-3-4-5-6",+ };+ input.dispatchEvent(pasteEvent);++ await settled();++ assert.dom(".d-otp-slot:nth-child(1)").hasText(" 1");+ assert.dom(".d-otp-slot:nth-child(2)").hasText(" 2");+ assert.dom(".d-otp-slot:nth-child(3)").hasText(" 3");+ assert.dom(".d-otp-slot:nth-child(4)").hasText(" 4");+ assert.dom(".d-otp-slot:nth-child(5)").hasText(" 5");+ assert.dom(".d-otp-slot:nth-child(6)").hasText(" 6");+ });++ test("removes all content when all is selected and backspace is pressed", async function (assert) {+ await render(<template><DOTP /></template>);++ const input = this.element.querySelector(".d-otp-input");+ input.value = "123456";+ input.dispatchEvent(new Event("input"));++ await settled();++ assert.dom(".d-otp-slot:nth-child(1)").hasText(" 1");+ assert.dom(".d-otp-slot:nth-child(2)").hasText(" 2");+ assert.dom(".d-otp-slot:nth-child(3)").hasText(" 3");+ assert.dom(".d-otp-slot:nth-child(4)").hasText(" 4");+ assert.dom(".d-otp-slot:nth-child(5)").hasText(" 5");+ assert.dom(".d-otp-slot:nth-child(6)").hasText(" 6");++ input.select();+ input.value = ""; // Simulate backspace key+ input.dispatchEvent(new Event("input"));++ await settled();++ assert.dom(".d-otp-slot:nth-child(1)").hasText(" "); // first slot shows cursor+ assert.dom(".d-otp-slot:nth-child(2)").hasText(" -");+ assert.dom(".d-otp-slot:nth-child(3)").hasText(" -");+ assert.dom(".d-otp-slot:nth-child(4)").hasText(" -");+ assert.dom(".d-otp-slot:nth-child(5)").hasText(" -");+ assert.dom(".d-otp-slot:nth-child(6)").hasText(" -");+ });+});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.gjsnew file mode 100644index 00000000000..d6b71af624f--- /dev/null+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/atoms/07-otp.gjs@@ -0,0 +1,48 @@+import Component from "@glimmer/component";+import { tracked } from "@glimmer/tracking";+import { action } from "@ember/object";+import DOTP from "discourse/components/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;+ }+ }++ <template>+ <StyleguideExample @title="d-otp">+ <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="@slots={{4}}">+ <DOTP @slots={{4}} />+ </StyleguideExample>+ </template>+}diff --git a/plugins/styleguide/assets/javascripts/discourse/lib/styleguide.js b/plugins/styleguide/assets/javascripts/discourse/lib/styleguide.jsindex a02edd7d730..a937b13356b 100644--- a/plugins/styleguide/assets/javascripts/discourse/lib/styleguide.js+++ b/plugins/styleguide/assets/javascripts/discourse/lib/styleguide.js@@ -5,6 +5,7 @@ import colors from "../components/sections/atoms/03-colors";import icons from "../components/sections/atoms/04-icons";import forms from "../components/sections/atoms/05-forms";import spinners from "../components/sections/atoms/06-spinners";+import otp from "../components/sections/atoms/07-otp";import dateTimeInputs from "../components/sections/atoms/date-time-inputs";import dropdowns from "../components/sections/atoms/dropdowns";import topicLink from "../components/sections/atoms/topic-link";@@ -59,6 +60,7 @@ const SECTIONS = [priority: 5,},{ component: spinners, category: "atoms", id: "spinners", priority: 6 },+ { component: otp, category: "atoms", id: "otp", priority: 7 },{ component: dateTimeInputs, category: "atoms", id: "date-time-inputs" },{ component: dropdowns, category: "atoms", id: "dropdowns" },{ component: topicLink, category: "atoms", id: "topic-link" },diff --git a/plugins/styleguide/assets/stylesheets/styleguide.scss b/plugins/styleguide/assets/stylesheets/styleguide.scssindex 20148bc78b4..9914a146086 100644--- a/plugins/styleguide/assets/stylesheets/styleguide.scss+++ b/plugins/styleguide/assets/stylesheets/styleguide.scss@@ -64,6 +64,13 @@}.styleguide-example {+ output {+ border: 1px dotted var(--content-border-color);+ width: 100%;+ padding: 1rem;+ box-sizing: border-box;+ }+.example-title {color: var(--primary-medium);font-size: var(--font-down-1);@@ -74,6 +81,9 @@.rendered {width: 100%;position: relative;+ display: flex;+ flex-direction: column;+ gap: 0.5rem;.component-properties {width: 100%;diff --git a/plugins/styleguide/config/locales/client.en.yml b/plugins/styleguide/config/locales/client.en.ymlindex 9f316e5c9a0..c3a98448cf5 100644--- a/plugins/styleguide/config/locales/client.en.yml+++ b/plugins/styleguide/config/locales/client.en.yml@@ -101,6 +101,8 @@ en:title: "Header Icons"spinners:title: "Spinners"+ otp:+ title: "OTP"empty_state:title: "Empty State"tooltips:diff --git a/plugins/styleguide/spec/system/smoke_test_spec.rb b/plugins/styleguide/spec/system/smoke_test_spec.rbindex 46e73452e95..95d6148134d 100644--- a/plugins/styleguide/spec/system/smoke_test_spec.rb+++ b/plugins/styleguide/spec/system/smoke_test_spec.rb@@ -14,6 +14,7 @@ RSpec.describe "Styleguide Smoke Test", type: :system do{ href: "/atoms/icons", title: "Icons" },{ href: "/atoms/forms", title: "Forms" },{ href: "/atoms/spinners", title: "Spinners" },+ { href: "/atoms/otp", title: "OTP" },{ href: "/atoms/date-time-inputs", title: "Date/Time inputs" },{ href: "/atoms/dropdowns", title: "Dropdowns" },{ href: "/atoms/topic-link", title: "Topic Link" },