Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/

import { HdsApplicationState } from '@hashicorp/design-system-components/components';

import type { TemplateOnlyComponent } from '@ember/component/template-only';
import type { HdsApplicationStateSignature } from '@hashicorp/design-system-components/components/hds/application-state/index';

export interface CodeFragmentWithActionVariantsSignature {
Args: {
align: HdsApplicationStateSignature['Args']['align'];
hasDropdown?: boolean;
hasPrimaryAction?: boolean;
hasSecondaryAction?: boolean;
hasStandaloneLink?: boolean;
};
Element: HdsApplicationStateSignature['Element'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[note] technically this is not necessary, since we're not spreading the ...attributes operator

}

const CodeFragmentWithActionVariants: TemplateOnlyComponent<CodeFragmentWithActionVariantsSignature> =
<template>
<HdsApplicationState @align={{@align}} as |A|>
<A.Header
@title="An error has occurred"
@icon="alert-circle"
@errorCode="404"
/>
<A.Body
@text="Sorry, an unexpected error has occurred. Please try again later or contact support for assistance."
/>
<A.Footer as |F|>
{{#if @hasPrimaryAction}}
<F.Button @color="primary" @text="Primary action" />
{{/if}}

{{#if @hasSecondaryAction}}
<F.Button @color="secondary" @text="Secondary action" />
{{/if}}

{{#if @hasDropdown}}
<F.Dropdown @listPosition="bottom-right" as |dd|>
<dd.ToggleButton @text="Choose an option" />
<dd.Title @text="Categories" />
<dd.Interactive @href="#">Documentation</dd.Interactive>
<dd.Interactive @href="#">Tutorials</dd.Interactive>
<dd.Interactive @href="#">Changelogs</dd.Interactive>
</F.Dropdown>
{{/if}}

{{#if @hasStandaloneLink}}
<F.LinkStandalone
@icon="docs-link"
@text="Learn more"
@iconPosition="trailing"
@href="#"
/>
{{/if}}
</A.Footer>
</HdsApplicationState>
</template>;

export default CodeFragmentWithActionVariants;
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/

import Component from '@glimmer/component';
import { eq } from 'ember-truth-helpers';

import {
HdsApplicationState,
HdsIcon,
HdsIconTile,
} from '@hashicorp/design-system-components/components';

import ShwPlaceholder from 'showcase/components/shw/placeholder';

import type { HdsApplicationStateSignature } from '@hashicorp/design-system-components/components/hds/application-state/index';
import type { HdsApplicationStateHeaderSignature } from '@hashicorp/design-system-components/components/hds/application-state/header';

enum CodeFragmentWithErrorContentActionsValues {
Primary = 'primary',
Secondary = 'secondary',
StandaloneLink = 'standaloneLink',
}

type CodeFragmentWithErrorContentActions =
`${CodeFragmentWithErrorContentActionsValues}`;

enum CodeFragmentWithErrorContentMediaValues {
Icon = 'icon',
IconTile = 'icon-tile',
Image = 'image',
Generic = 'generic',
}

type CodeFragmentWithErrorContentMedia =
`${CodeFragmentWithErrorContentMediaValues}`;

interface CodeFragmentWithErrorContentSignature {
Args: {
actions?: Array<CodeFragmentWithErrorContentActions>;
align?: HdsApplicationStateSignature['Args']['align'];
bodyText?: string;
hasErrorCode?: boolean;
media?: CodeFragmentWithErrorContentMedia;
icon?: HdsApplicationStateHeaderSignature['Args']['icon'];
titleTag?: HdsApplicationStateHeaderSignature['Args']['titleTag'];
titleText?: string;
};
Element: HdsApplicationStateSignature['Element'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[note] technically this is not necessary, since we're not spreading the ...attributes operator

}

export default class CodeFragmentWithErrorContent extends Component<CodeFragmentWithErrorContentSignature> {
get titleText() {
return this.args.titleText ?? 'An error has occurred';
}

get bodyText() {
return (
this.args.bodyText ??
'Sorry, an unexpected error has occurred. Please try again later or contact support for assistance.'
);
}

includesAction = (action: CodeFragmentWithErrorContentActions) => {
return this.args.actions?.includes(action);
};

<template>
<HdsApplicationState @align={{@align}} as |A|>
{{#if @media}}
<A.Media>
{{#if (eq @media "icon")}}
<HdsIcon @name="channel" @size="24" />
{{else if (eq @media "icon-tile")}}
<HdsIconTile @logo="terraform" @size="large" />
{{else if (eq @media "image")}}
<img
src="/assets/images/cat-banner.png"
alt="3 cats wearing old-fashioned formal wear"
class="shw-component-application-state-banner"
/>
{{else if (eq @media "generic")}}
<ShwPlaceholder @text="media" @width="80" @height="80" />
{{/if}}
</A.Media>
{{/if}}
<A.Header
@title={{this.titleText}}
@titleTag={{@titleTag}}
@icon={{@icon}}
@errorCode={{if @hasErrorCode "404"}}
/>
<A.Body @text={{this.bodyText}} />
<A.Footer as |F|>
{{#if (this.includesAction "primary")}}
<F.Button @color="primary" @text="Primary action" />
{{/if}}
{{#if (this.includesAction "secondary")}}
<F.Button @color="secondary" @text="Secondary action" />
{{/if}}
{{#if (this.includesAction "standaloneLink")}}
<F.LinkStandalone @icon="arrow-left" @text="Go back" @href="/" />
{{/if}}
</A.Footer>
</HdsApplicationState>
</template>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/

import { HdsApplicationState } from '@hashicorp/design-system-components/components';

import type { TemplateOnlyComponent } from '@ember/component/template-only';
import type { HdsApplicationStateSignature } from '@hashicorp/design-system-components/components/hds/application-state/index';

interface CodeFragmentWithGenericContentSignature {
Element: HdsApplicationStateSignature['Element'];
}

const CodeFragmentWithGenericContent: TemplateOnlyComponent<CodeFragmentWithGenericContentSignature> =
Comment on lines +11 to +15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
interface CodeFragmentWithGenericContentSignature {
Element: HdsApplicationStateSignature['Element'];
}
const CodeFragmentWithGenericContent: TemplateOnlyComponent<CodeFragmentWithGenericContentSignature> =
const CodeFragmentWithGenericContent: TemplateOnlyComponent =

<template>
<HdsApplicationState @align="center" as |A|>
<A.Header @title="No stacks" />
<A.Body @text="No stacks to show in this project." />
<A.Footer as |F|>
<F.Button @color="primary" @text="Create stack" />
</A.Footer>
</HdsApplicationState>
</template>;

export default CodeFragmentWithGenericContent;
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/

import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { pageTitle } from 'ember-page-title';

import ShwTextH1 from 'showcase/components/shw/text/h1';

import SubSectionAlignment from 'showcase/components/page-components/application-state/sub-sections/alignment';
import SubSectionContent from 'showcase/components/page-components/application-state/sub-sections/content';
import SubSectionContainer from 'showcase/components/page-components/application-state/sub-sections/container';
import SubSectionResponsiveness from 'showcase/components/page-components/application-state/sub-sections/responsiveness';
import SubSectionWithMedia from 'showcase/components/page-components/application-state/sub-sections/with-media';

export default class ApplicationStateIndex extends Component {
@tracked showHighlight = false;

toggleHighlight = () => {
this.showHighlight = !this.showHighlight;
};

<template>
{{pageTitle "ApplicationState Component"}}

<ShwTextH1>ApplicationState</ShwTextH1>

<section
data-test-percy
class="{{if
this.showHighlight
'shw-component-application-state-layout-highlight'
}}"
>
<SubSectionContent
@showHighlight={{this.showHighlight}}
@toggleHighlight={{this.toggleHighlight}}
/>
<SubSectionAlignment
@showHighlight={{this.showHighlight}}
@toggleHighlight={{this.toggleHighlight}}
/>
<SubSectionWithMedia
@showHighlight={{this.showHighlight}}
@toggleHighlight={{this.toggleHighlight}}
/>
<SubSectionResponsiveness
@showHighlight={{this.showHighlight}}
@toggleHighlight={{this.toggleHighlight}}
/>
<SubSectionContainer
@showHighlight={{this.showHighlight}}
@toggleHighlight={{this.toggleHighlight}}
/>
</section>
</template>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/

import { on } from '@ember/modifier';
import { capitalize } from '@ember/string';
import { eq } from 'ember-truth-helpers';

import ShwFlex from 'showcase/components/shw/flex';
import ShwTextH2 from 'showcase/components/shw/text/h2';
import ShwDivider from 'showcase/components/shw/divider';
import { ALIGNS } from '@hashicorp/design-system-components/components/hds/application-state/index';

import CodeFragmentWithActionVariants from '../code-fragments/with-action-variants';

import type { TemplateOnlyComponent } from '@ember/component/template-only';

export interface SubSectionAlignmentSignature {
Args: {
showHighlight: boolean;
toggleHighlight: () => void;
};
}

const SubSectionAlignment: TemplateOnlyComponent<SubSectionAlignmentSignature> =
<template>
<ShwTextH2>Alignment</ShwTextH2>

<button
type="button"
class="shw-component-application-state-button-highlight"
{{on "click" @toggleHighlight}}
>
{{if @showHighlight "Hide" "Show"}}
layout highlight
</button>

<ShwFlex @direction="row" @gap="4rem" as |SF|>
{{#each ALIGNS as |align|}}
<SF.Item
@label="{{capitalize align}} aligned {{if
(eq align 'left')
' (default)'
}}"
>
<CodeFragmentWithActionVariants
@align={{align}}
@hasStandaloneLink={{true}}
/>
</SF.Item>
{{/each}}
{{#each ALIGNS as |align|}}
<SF.Item @label="Two actions / {{align}} aligned">
<CodeFragmentWithActionVariants
@align={{align}}
@hasPrimaryAction={{true}}
@hasStandaloneLink={{true}}
/>
</SF.Item>
{{/each}}
{{#each ALIGNS as |align|}}
<SF.Item @label="Three actions / {{align}} aligned">
<CodeFragmentWithActionVariants
@align={{align}}
@hasPrimaryAction={{true}}
@hasSecondaryAction={{true}}
@hasStandaloneLink={{true}}
/>
</SF.Item>
{{/each}}
{{#each ALIGNS as |align|}}
<SF.Item @label="Two actions (1 dropdown) / {{align}} aligned">
<CodeFragmentWithActionVariants
@align={{align}}
@hasDropdown={{true}}
@hasPrimaryAction={{true}}
/>
</SF.Item>
{{/each}}
{{#each ALIGNS as |align|}}
<SF.Item @label="Three actions (1 dropdown) / {{align}} aligned">
<CodeFragmentWithActionVariants
@align={{align}}
@hasDropdown={{true}}
@hasPrimaryAction={{true}}
@hasStandaloneLink={{true}}
/>
</SF.Item>
{{/each}}
</ShwFlex>

<ShwDivider />
</template>;

export default SubSectionAlignment;
Loading