From c88cb3f4dd8a4c4bffe670b2aa1908457e364b49 Mon Sep 17 00:00:00 2001 From: Cristiano Rastelli Date: Tue, 17 Dec 2024 20:22:35 +0000 Subject: [PATCH] =?UTF-8?q?added=20=E2=80=9Cdemo=E2=80=9D=20frameless=20pa?= =?UTF-8?q?ge=20for=20theming=20testing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/hds/theme-switcher/index.hbs | 1 + showcase/app/components/mock/app/index.gts | 24 +- .../components/mock/app/main/form-complex.gts | 357 ++++++++++++++++++ .../mock/app/main/generic-text-content.gts | 16 +- .../components/mock/app/main/pagination.gts | 31 ++ .../mock/app/main/table-complex.gts | 191 ++++++++++ .../components/mock/app/sidebar/side-nav.gts | 2 + .../demo-application-with-theme-switcher.js | 12 + .../{theming.js => theming/index.js} | 0 showcase/app/router.ts | 6 +- .../demo-application-with-theme-switcher.hbs | 307 +++++++++++++++ .../{theming.hbs => theming/index.hbs} | 0 showcase/types/template-registry.ts | 9 + 13 files changed, 953 insertions(+), 3 deletions(-) create mode 100644 showcase/app/components/mock/app/main/form-complex.gts create mode 100644 showcase/app/components/mock/app/main/pagination.gts create mode 100644 showcase/app/components/mock/app/main/table-complex.gts create mode 100644 showcase/app/controllers/foundations/theming/frameless/demo-application-with-theme-switcher.js rename showcase/app/controllers/foundations/{theming.js => theming/index.js} (100%) create mode 100644 showcase/app/templates/foundations/theming/frameless/demo-application-with-theme-switcher.hbs rename showcase/app/templates/foundations/{theming.hbs => theming/index.hbs} (100%) diff --git a/packages/components/src/components/hds/theme-switcher/index.hbs b/packages/components/src/components/hds/theme-switcher/index.hbs index 01f5c5cdd2c..97bf5999b53 100644 --- a/packages/components/src/components/hds/theme-switcher/index.hbs +++ b/packages/components/src/components/hds/theme-switcher/index.hbs @@ -5,6 +5,7 @@ diff --git a/showcase/app/components/mock/app/index.gts b/showcase/app/components/mock/app/index.gts index bf583de6cdd..5beeb3814e6 100644 --- a/showcase/app/components/mock/app/index.gts +++ b/showcase/app/components/mock/app/index.gts @@ -9,10 +9,16 @@ import MockAppHeaderAppHeader from './header/app-header'; import MockAppSidebarSideNav from './sidebar/side-nav'; import MockAppMainPageHeader from './main/page-header'; import MockAppMainGenericTextContent from './main/generic-text-content'; +import MockAppMainFormComplex from './main/form-complex'; +import MockAppMainTableComplex from './main/table-complex'; +import MockAppMainPagination from './main/pagination'; import MockAppFooterAppFooter from './footer/app-footer'; // HDS components -import { HdsAppFrame } from '@hashicorp/design-system-components/components'; +import { + HdsAlert, + HdsAppFrame, +} from '@hashicorp/design-system-components/components'; // types import type { ComponentLike } from '@glint/template'; @@ -21,10 +27,14 @@ import type { MockAppHeaderAppHeaderSignature } from './header/app-header'; import type { MockAppSidebarSideNavSignature } from './sidebar/side-nav'; import type { MockAppMainPageHeaderSignature } from './main/page-header'; import type { MockAppMainGenericTextContentSignature } from './main/generic-text-content'; +import type { MockAppMainFormComplexSignature } from './main/form-complex'; +import type { MockAppMainTableComplexSignature } from './main/table-complex'; +import type { MockAppMainPaginationSignature } from './main/pagination'; import type { MockAppFooterAppFooterSignature } from './footer/app-footer'; export interface MockAppSignature { Args: { + hasPageAlert?: boolean; hasHeader?: HdsAppFrameSignature['Args']['hasHeader']; hasSidebar?: HdsAppFrameSignature['Args']['hasSidebar']; hasFooter?: HdsAppFrameSignature['Args']['hasFooter']; @@ -44,6 +54,9 @@ export interface MockAppSignature { { PageHeader?: ComponentLike; GenericTextContent?: ComponentLike; + MockAppMainFormComplex?: ComponentLike; + MockAppMainTableComplex?: ComponentLike; + MockAppMainPagination?: ComponentLike; }, ]; footer?: [ @@ -80,11 +93,20 @@ export default class MockApp extends Component { {{/if}} + {{#if @hasPageAlert}} + + Lorem ipsum + Lorem ipsum dolor sit amet. + + {{/if}}
{{yield (hash PageHeader=MockAppMainPageHeader GenericTextContent=MockAppMainGenericTextContent + FormComplex=MockAppMainFormComplex + TableComplex=MockAppMainTableComplex + Pagination=MockAppMainPagination ) to="main" }} diff --git a/showcase/app/components/mock/app/main/form-complex.gts b/showcase/app/components/mock/app/main/form-complex.gts new file mode 100644 index 00000000000..d9198fc8094 --- /dev/null +++ b/showcase/app/components/mock/app/main/form-complex.gts @@ -0,0 +1,357 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: MPL-2.0 + */ + +import Component from '@glimmer/component'; +import style from 'ember-style-modifier/modifiers/style'; + +// HDS components +import { + HdsButton, + HdsButtonSet, + HdsFormCheckboxGroup, + HdsFormFileInputField, + HdsFormMaskedInputField, + HdsFormRadioGroup, + HdsFormRadioCardGroup, + HdsFormSelectField, + HdsFormSuperSelectSingleField, + HdsFormSuperSelectMultipleField, + HdsFormTextInputField, + HdsFormTextareaField, + HdsFormToggleField, + HdsLinkInline, + HdsSeparator, + HdsTextBody, + HdsTextDisplay, +} from '@hashicorp/design-system-components/components'; + +const RADIOCARDS = [ + { + value: '1', + label: 'Radio card label 1', + badge: 'Badge', + checked: true, + description: 'Radio card description 1', + generic: 'Radio card custom content 1', + }, + { + value: '2', + label: 'Radio card label 2', + badge: 'Badge', + description: 'Radio card description 2', + generic: 'Radio card custom content 2', + }, + { + value: '3', + label: 'Radio card label 3', + badge: 'Badge', + description: 'Radio card description 3', + generic: 'Radio card custom content 3', + }, +]; + +const SUPERSELECT1_OPTIONS = [ + { + size: 'Extra Small', + description: '2 vCPU | 1 GiB RAM', + price: '$0.02', + }, + { + size: 'Small', + description: '2 vCPU | 2 GiB RAM', + price: '$0.04', + disabled: true, + }, + { + size: 'Medium', + description: '4 vCPU | 4 GiB RAM', + price: '$0.08', + disabled: true, + }, + { size: 'Large', description: '8 vCPU | 8 GiB RAM', price: '$0.16' }, + { + size: 'Extra Large', + description: '16 vCPU | 16 GiB RAM', + price: '$0.32', + }, +]; +const SELECTED_SUPERSELECT1_OPTION = SUPERSELECT1_OPTIONS[1]; + +const SUPERSELECT2_OPTIONS = ['Option 1', 'Option 2', 'Option 3']; +const SELECTED_SUPERSELECT2_OPTIONS = [ + SUPERSELECT2_OPTIONS[0], + SUPERSELECT2_OPTIONS[1], +]; + +const noop = () => {}; + +export interface MockAppMainFormComplexSignature { + Args: { + showErrors?: boolean; + showIntro?: boolean; + showCheckbox?: boolean; + showFileInput?: boolean; + showMaskedInput?: boolean; + showRadio?: boolean; + showRadioCard?: boolean; + showSelect?: boolean; + showSuperSelect?: boolean; + showTextarea?: boolean; + showTextInput?: boolean; + showToggle?: boolean; + showButtons?: boolean; + showErrors?: boolean; + }; + Element: HTMLDivElement; +} + +export default class MockAppMainFormComplex extends Component { + _showIntro; + _showCheckbox; + _showFileInput; + _showMaskedInput; + _showRadio; + _showRadioCard; + _showSelect; + _showSuperSelect; + _showTextarea; + _showTextInput; + _showToggle; + _showButtons; + _showErrors; + + constructor(owner: unknown, args: MockAppMainFormComplexSignature['Args']) { + super(owner, args); + this._showIntro = this.args.showIntro ?? this.args.showAll ?? false; + this._showCheckbox = this.args.showCheckbox ?? this.args.showAll ?? false; + this._showFileInput = this.args.showFileInput ?? this.args.showAll ?? false; + this._showMaskedInput = + this.args.showMaskedInput ?? this.args.showAll ?? false; + this._showRadio = this.args.showRadio ?? this.args.showAll ?? false; + this._showRadioCard = this.args.showRadioCard ?? this.args.showAll ?? false; + this._showSelect = this.args.showSelect ?? this.args.showAll ?? false; + this._showSuperSelect = + this.args.showSuperSelect ?? this.args.showAll ?? false; + this._showTextarea = this.args.showTextarea ?? this.args.showAll ?? false; + this._showToggle = this.args.showToggle ?? this.args.showAll ?? false; + this._showErrors = this.args.showErrors ?? this.args.showAll ?? false; + // we want at least something to be visible by default + this._showTextInput = this.args.showTextInput ?? this.args.showAll ?? true; + this._showButtons = this.args._showButtons ?? this.args.showAll ?? true; + } + + +} diff --git a/showcase/app/components/mock/app/main/generic-text-content.gts b/showcase/app/components/mock/app/main/generic-text-content.gts index 9c15bb89b5c..5a24e765690 100644 --- a/showcase/app/components/mock/app/main/generic-text-content.gts +++ b/showcase/app/components/mock/app/main/generic-text-content.gts @@ -6,14 +6,22 @@ // HDS components import { HdsLinkInline, + HdsTextDisplay, HdsTextBody, } from '@hashicorp/design-system-components/components'; // eslint-disable-next-line @typescript-eslint/no-empty-object-type -export interface MockAppMainGenericTextContentSignature {} +export interface MockAppMainGenericTextContentSignature { + Args: { + showHeadings?: boolean; + }; +}