Skip to content
Merged
Show file tree
Hide file tree
Changes from 56 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
7b54b69
added new yielded media component
zamoore Jul 16, 2024
481cb31
yielding new media component from parent ApplicationState component
zamoore Jul 16, 2024
62a52d5
updating docs to better reflect component defaults
zamoore Jul 17, 2024
23badf3
converted index from template-only component
zamoore Jul 17, 2024
aabc344
added default left alignment to ApplicationState index
zamoore Jul 17, 2024
db7bddb
updating application-state styles
zamoore Jul 17, 2024
7f5aed7
moved the error code above the title and title icon
zamoore Jul 17, 2024
e52f3eb
updated text styles
zamoore Jul 17, 2024
86e7837
alignment classes - wip
zamoore Jul 18, 2024
2a524a8
fixed center alignment issue
zamoore Jul 18, 2024
3a2c9fa
figured out an alternative that didn't require updating the structure…
zamoore Jul 18, 2024
e08b983
adjusting footer padding
zamoore Jul 18, 2024
ebc298c
actions are displayed correctly
zamoore Jul 18, 2024
edb4446
cleaning up documentation
zamoore Jul 18, 2024
d595db8
adding visual test cases for larger images
zamoore Jul 19, 2024
c834b98
final using flexbox
zamoore Jul 19, 2024
5696958
implemented left aligned version
zamoore Jul 19, 2024
87c41f5
updated showcase page to include a β€œhighlight” button
didoo Jul 22, 2024
914f2d5
added `Button` as yielded component for the `ApplicationState::Footer…
didoo Jul 22, 2024
b04179a
extended showcase with more use cases and reorganized existing content
didoo Jul 22, 2024
0921439
added a changeset
zamoore Jul 24, 2024
79abaa1
addressing broken color in icon
zamoore Jul 24, 2024
e06bd08
Update changeset
zamoore Jul 24, 2024
99d0094
adding integration tests
zamoore Jul 24, 2024
b90192d
fixing align getter
zamoore Jul 24, 2024
f077cd2
self-pr review adjustments
zamoore Jul 24, 2024
4e0501a
adding additional test for invalid align value
zamoore Jul 24, 2024
d0c3e76
adjusting spacing
zamoore Jul 25, 2024
5a42f7c
removed old content from showcase for `ApplicationState`
didoo Jul 25, 2024
2319640
Update changeset to follow team conventions
zamoore Jul 25, 2024
8206c8d
reordering TS def for team conformity
zamoore Jul 25, 2024
8a2a8bb
small update to the showcase
didoo Jul 25, 2024
6cb232e
adjust title color
zamoore Jul 25, 2024
fbfc239
Update color for error code
zamoore Jul 25, 2024
83d2eeb
Update icon color
zamoore Jul 25, 2024
448f644
add use cases to the ApplicationState showcase where it’s inside a co…
didoo Jul 25, 2024
be039bb
responging to pr feedback
zamoore Jul 25, 2024
c654e4f
updating tests to follow standard assertion patterns
zamoore Jul 25, 2024
0a13e85
fix linting error
zamoore Jul 25, 2024
6456c6d
added new integration test for the media component
zamoore Jul 25, 2024
bc7d905
remove footer border option
zamoore Jul 29, 2024
7f14f83
removed test related to deleted code
zamoore Jul 29, 2024
266094c
added components to export
zamoore Jul 29, 2024
453ce24
added dropdown as potentially yielded footer item
zamoore Jul 29, 2024
f5fdaa6
added a bottom margin to the error code element
zamoore Jul 30, 2024
b7e835c
fixed color on error code
zamoore Jul 30, 2024
8c40c99
added custom title tag option
zamoore Jul 31, 2024
f4d85d2
added showcase examples and tests for the titleTag attribute
zamoore Jul 31, 2024
4a4ffa3
added new tests for contextual component rendering to index component
zamoore Jul 31, 2024
d4e7a05
added dropdown action to showcase
zamoore Jul 31, 2024
fc40402
responding to PR feedback; commenting on usage of named css colors in…
zamoore Jul 31, 2024
f3610b3
updated the changeset to include comprehensive details on the scope o…
zamoore Jul 31, 2024
8b7dea4
fixed failing test
zamoore Jul 31, 2024
6cd36ce
adding mroe examples in showcase
zamoore Aug 1, 2024
b581cb7
Update .changeset
zamoore Aug 1, 2024
4cda0d6
addressing pr feedback
zamoore Aug 1, 2024
bee9d67
Apply suggestions from code review
zamoore Aug 1, 2024
57046dd
`ApplicationState` Enhancements - Documentation (#2269)
majedelass Aug 1, 2024
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
17 changes: 17 additions & 0 deletions .changeset/shaggy-apes-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
"@hashicorp/design-system-components": minor
---

`ApplicationState`:

- Spacing and alignment updates
- New `@align` (`left` (default), `center`) argument for aligning content
- Added new yielded `Media` child component

`ApplicationState::Header`:

- The header now supports an optional `@titleTag` argument that can override the default title element (`div`)

`ApplicationState::Footer`:

- The footer now yields `Button` and `Dropdown` components as well as `LinkStandalone`
1 change: 1 addition & 0 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
"./components/hds/application-state/footer.js": "./dist/_app_/components/hds/application-state/footer.js",
"./components/hds/application-state/header.js": "./dist/_app_/components/hds/application-state/header.js",
"./components/hds/application-state/index.js": "./dist/_app_/components/hds/application-state/index.js",
"./components/hds/application-state/media.js": "./dist/_app_/components/hds/application-state/media.js",
"./components/hds/badge-count/index.js": "./dist/_app_/components/hds/badge-count/index.js",
"./components/hds/badge/index.js": "./dist/_app_/components/hds/badge/index.js",
"./components/hds/breadcrumb/index.js": "./dist/_app_/components/hds/breadcrumb/index.js",
Expand Down
8 changes: 8 additions & 0 deletions packages/components/src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import HdsAlert from './components/hds/alert/index.ts';
import HdsAppFooter from './components/hds/app-footer/index.ts';
import HdsAppFrame from './components/hds/app-frame/index.ts';
import HdsApplicationState from './components/hds/application-state/index.ts';
import HdsApplicationStateBody from './components/hds/application-state/body.ts';
import HdsApplicationStateFooter from './components/hds/application-state/footer.ts';
import HdsApplicationStateHeader from './components/hds/application-state/header.ts';
import HdsApplicationStateMedia from './components/hds/application-state/media.ts';
import HdsBadge from './components/hds/badge/index.ts';
import HdsBadgeCount from './components/hds/badge-count/index.ts';
import HdsBreadcrumb from './components/hds/breadcrumb/index.ts';
Expand Down Expand Up @@ -102,6 +106,10 @@ export {
HdsAppFooter,
HdsAppFrame,
HdsApplicationState,
HdsApplicationStateBody,
HdsApplicationStateFooter,
HdsApplicationStateHeader,
HdsApplicationStateMedia,
HdsBadge,
HdsBadgeCount,
HdsBreadcrumb,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
SPDX-License-Identifier: MPL-2.0
}}

<div class={{this.classNames}} ...attributes>
{{yield (hash LinkStandalone=(component "hds/link/standalone"))}}
<div class="hds-application-state__footer" ...attributes>
{{yield
(hash
Button=(component "hds/button")
Dropdown=(component "hds/dropdown")
LinkStandalone=(component "hds/link/standalone")
)
}}
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
* SPDX-License-Identifier: MPL-2.0
*/

import Component from '@glimmer/component';
import TemplateOnlyComponent from '@ember/component/template-only';
import type { ComponentLike } from '@glint/template';
import type { HdsLinkStandaloneSignature } from '../link/standalone';
import type { HdsButtonSignature } from '../button';
import type { HdsDropdownSignature } from 'src/components/hds/dropdown';

export interface HdsApplicationStateFooterSignature {
Args: {
Expand All @@ -14,38 +16,16 @@ export interface HdsApplicationStateFooterSignature {
Blocks: {
default?: [
{
Button?: ComponentLike<HdsButtonSignature>;
Dropdown?: ComponentLike<HdsDropdownSignature>;
LinkStandalone?: ComponentLike<HdsLinkStandaloneSignature>;
},
];
};
Element: HTMLDivElement;
}

export default class HdsApplicationStateFooterComponent extends Component<HdsApplicationStateFooterSignature> {
/**
* Indicate if the footer should have a top border or not.
*
* @param hasDivider
* @type {boolean}
* @default false
*/
get hasDivider(): boolean {
return this.args.hasDivider ?? false;
}
const HdsApplicationStateFooterComponent =
TemplateOnlyComponent<HdsApplicationStateFooterSignature>();

/**
* Get the class names to apply to the component.
* @method classNames
* @return {string} The "class" attribute to apply to the component.
*/
get classNames(): string {
const classes = ['hds-application-state__footer'];

// add a class based on the existence of @hasDivider argument
if (this.hasDivider) {
classes.push(`hds-application-state__footer--has-divider`);
}

return classes.join(' ');
}
}
export default HdsApplicationStateFooterComponent;
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,24 @@
SPDX-License-Identifier: MPL-2.0
}}
<div class="hds-application-state__header" ...attributes>
{{#if @errorCode}}
<Hds::Text::Body class="hds-application-state__error-code" @tag="div" @size="100" @weight="medium" @color="faint">
ERROR
{{@errorCode}}
</Hds::Text::Body>
{{/if}}
{{#if @icon}}
<div class="hds-application-state__icon">
<FlightIcon @name={{@icon}} @size="24" />
<FlightIcon @color="var(--token-color-foreground-strong)" @name={{@icon}} @size="24" />
</div>
{{/if}}
<Hds::Text::Display class="hds-application-state__title" @tag="div" @size="400" @weight="semibold">
<Hds::Text::Display
class="hds-application-state__title"
@tag={{this.titleTag}}
@size="300"
@weight="semibold"
@color="strong"
>
{{@title}}
</Hds::Text::Display>
{{#if @errorCode}}
<Hds::Text::Body class="hds-application-state__error-code" @tag="div" @size="100" @weight="medium">
Error
{{@errorCode}}
</Hds::Text::Body>
{{/if}}
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@
* SPDX-License-Identifier: MPL-2.0
*/

import TemplateOnlyComponent from '@ember/component/template-only';
import Component from '@glimmer/component';

import type { FlightIconSignature } from '@hashicorp/ember-flight-icons/components/flight-icon';

import type { HdsTextDisplaySignature } from '../text/display';
export interface HdsApplicationStateHeaderSignature {
Args: {
title?: string;
titleTag?: HdsTextDisplaySignature['Args']['tag'];
errorCode?: string;
icon?: FlightIconSignature['Args']['name'];
};
Element: HTMLDivElement;
}

const HdsApplicationStateHeaderComponent =
TemplateOnlyComponent<HdsApplicationStateHeaderSignature>();

export default HdsApplicationStateHeaderComponent;
export default class HdsApplicationStateHeaderComponent extends Component<HdsApplicationStateHeaderSignature> {
get titleTag() {
return this.args.titleTag ?? 'div';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: MPL-2.0
}}
<div class="hds-application-state" ...attributes>
<div class={{this.classNames}} ...attributes>
{{yield
(hash
Media=(component "hds/application-state/media")
Header=(component "hds/application-state/header")
Body=(component "hds/application-state/body")
Footer=(component "hds/application-state/footer")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,26 @@
* SPDX-License-Identifier: MPL-2.0
*/

import TemplateOnlyComponent from '@ember/component/template-only';
import Component from '@glimmer/component';
import { assert } from '@ember/debug';
import { HdsApplicationStateAlignValues } from './types.ts';

import type { ComponentLike } from '@glint/template';
import type { HdsApplicationStateAligns } from './types';
import type { HdsApplicationStateMediaSignature } from './media';
import type { HdsApplicationStateHeaderSignature } from './header';
import type { HdsApplicationStateBodySignature } from './body';
import type { HdsApplicationStateFooterSignature } from './footer';

export const ALIGNS: string[] = Object.values(HdsApplicationStateAlignValues);
export interface HdsApplicationStateSignature {
Args: {
align?: HdsApplicationStateAligns;
};
Blocks: {
default: [
{
Media?: ComponentLike<HdsApplicationStateMediaSignature>;
Header?: ComponentLike<HdsApplicationStateHeaderSignature>;
Body?: ComponentLike<HdsApplicationStateBodySignature>;
Footer?: ComponentLike<HdsApplicationStateFooterSignature>;
Expand All @@ -22,7 +32,28 @@ export interface HdsApplicationStateSignature {
Element: HTMLDivElement;
}

const HdsApplicationStateComponent =
TemplateOnlyComponent<HdsApplicationStateSignature>();
export default class HdsApplicationStateComponent extends Component<HdsApplicationStateSignature> {
get align(): HdsApplicationStateAligns {
const validAlignValues: HdsApplicationStateAligns[] = Object.values(
HdsApplicationStateAlignValues
);

assert(
`@align for "Hds::ApplicationState" must be one of the following: ${validAlignValues.join(
', '
)}; received: ${this.args.align}`,
this.args.align == null || validAlignValues.includes(this.args.align)
);

return this.args.align ?? HdsApplicationStateAlignValues.Left;
}

export default HdsApplicationStateComponent;
get classNames(): string {
const classes = ['hds-application-state'];

// add a class based on the @align argument
classes.push(`hds-application-state--align-${this.align}`);

return classes.join(' ');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: MPL-2.0
}}

<div class="hds-application-state__media" ...attributes>
{{yield}}
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/

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

export interface HdsApplicationStateMediaSignature {
Blocks: {
default: [];
};
Element: HTMLDivElement;
}

const HdsApplicationStateMediaComponent =
TemplateOnlyComponent<HdsApplicationStateMediaSignature>();

export default HdsApplicationStateMediaComponent;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export enum HdsApplicationStateAlignValues {
Left = 'left',
Center = 'center',
}
export type HdsApplicationStateAligns = `${HdsApplicationStateAlignValues}`;
71 changes: 56 additions & 15 deletions packages/components/src/styles/components/application-state.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,84 @@
// APPLICATION-STATE COMPONENT
//

$hds-application-state-padding: 12px 0;
$hds-application-state-content-max-width: 480px;

.hds-application-state {
width: 19.5rem;
max-width: 100%;
display: flex;
flex-direction: column;
align-items: start;
width: fit-content;
margin: 0 auto; // this will center the component in the parent container

&.hds-application-state--align-center {
align-items: center;
text-align: center;

.hds-application-state__header,
.hds-application-state__body,
.hds-application-state__footer {
width: auto;
}
}
}

.hds-application-state__media {
margin-bottom: 32px;

> * {
display: block;
max-width: 100%;
}
}

.hds-application-state__header {
display: grid;
grid-template-areas:
"error error"
"icon title";
grid-template-columns: min-content 1fr;
align-items: start;
color: var(--token-color-foreground-faint);
align-items: center;
width: 100%;
max-width: $hds-application-state-content-max-width;
color: var(--token-color-foreground-strong);
}

.hds-application-state__error-code {
grid-area: error;
margin-bottom: 4px;
}

.hds-application-state__icon {
grid-area: icon;
margin-right: 8px; // instead of column gap
padding-top: 4px; // this seems to align the icon along with line 21
}

.hds-application-state__title,
.hds-application-state__error-code {
grid-column-start: 2;
.hds-application-state__title {
grid-row: 2;
font-weight: var(--token-typography-font-weight-semibold);

&:not(.hds-application-state__icon + &) {
grid-column: icon / title;
}
}

.hds-application-state__body {
padding: $hds-application-state-padding;
color: var(--token-color-foreground-faint);
width: 100%;
max-width: $hds-application-state-content-max-width;
margin: 12px 0 0;
color: var(--token-color-foreground-primary);
}

.hds-application-state__footer {
display: flex;
gap: 8px;
justify-content: space-between;
gap: 16px;
width: 100%;
max-width: $hds-application-state-content-max-width;
margin-top: 24px;

&.hds-application-state__footer--has-divider {
padding: $hds-application-state-padding;
border-top: 1px solid var(--token-color-border-strong);
// forces the third child and on to be on the right side
> :nth-child(3) {
margin-left: auto;
}
}
Loading