Skip to content

Commit

Permalink
Refactor sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffdaley committed Nov 9, 2023
1 parent 61cb8a9 commit 6ca7b85
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 30 deletions.
13 changes: 3 additions & 10 deletions web/app/components/doc/thumbnail.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import Component from "@glimmer/component";
import { dasherize } from "@ember/string";
import getProductId from "hermes/utils/get-product-id";
import { inject as service } from "@ember/service";
import ProductAreasService from "hermes/services/product-areas";
import { HermesSize } from "hermes/types/sizes";

export enum DocThumbnailSize {
Small = "small",
Medium = "medium",
Large = "large",
}
export type DocThumbnailSize = Exclude<HermesSize, HermesSize.XL>;

interface DocThumbnailComponentSignature {
Element: HTMLDivElement;
Expand All @@ -20,8 +15,6 @@ interface DocThumbnailComponentSignature {
}

export default class DocThumbnailComponent extends Component<DocThumbnailComponentSignature> {
@service declare productAreas: ProductAreasService;

protected get status(): string | null {
if (this.args.status) {
return dasherize(this.args.status);
Expand All @@ -31,7 +24,7 @@ export default class DocThumbnailComponent extends Component<DocThumbnailCompone
}

protected get size() {
return this.args.size ?? DocThumbnailSize.Small;
return this.args.size ?? HermesSize.Small;
}

protected get productShortName(): string | undefined {
Expand Down
8 changes: 3 additions & 5 deletions web/app/components/person/avatar.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import Component from "@glimmer/component";
import {
HermesBasicAvatarSize,
HermesPersonAvatarSize,
} from "hermes/types/avatar-size";
import { HermesPersonAvatarSize } from "hermes/types/avatar-size";
import { HermesSize } from "hermes/types/sizes";

interface PersonAvatarComponentSignature {
Element: HTMLDivElement;
Expand All @@ -18,7 +16,7 @@ interface PersonAvatarComponentSignature {
}

export default class PersonAvatarComponent extends Component<PersonAvatarComponentSignature> {
protected size = this.args.size ?? HermesBasicAvatarSize.Small;
protected size = this.args.size ?? HermesSize.Small;
}

declare module "@glint/environment-ember-loose/registry" {
Expand Down
8 changes: 5 additions & 3 deletions web/app/components/product/avatar.gts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import { inject as service } from "@ember/service";
import FlightIcon from "@hashicorp/ember-flight-icons/components/flight-icon";
import ProductAreasService from "hermes/services/product-areas";
import { assert } from "@ember/debug";
import { HermesBasicAvatarSize } from "hermes/types/avatar-size";
import { HermesSize } from "hermes/types/sizes";

export type ProductAvatarSize = Exclude<HermesSize, HermesSize.XL>;

interface ProductAvatarComponentSignature {
Element: HTMLDivElement;
Args: {
product?: string;
size?: `${HermesBasicAvatarSize}`;
size?: `${ProductAvatarSize}`;
};
Blocks: {
default: [];
Expand All @@ -27,7 +29,7 @@ export default class ProductAvatarComponent extends Component<ProductAvatarCompo
}

private get size() {
return this.args.size ?? HermesBasicAvatarSize.Small;
return this.args.size ?? HermesSize.Small;
}

<template>
Expand Down
14 changes: 2 additions & 12 deletions web/app/types/avatar-size.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
export enum HermesBasicAvatarSize {
Small = "small",
Medium = "medium",
Large = "large",
}
import { HermesSize } from "./sizes";

export enum HermesExtendedAvatarSize {
XL = "xl",
}

export type HermesPersonAvatarSize =
| HermesBasicAvatarSize
| HermesExtendedAvatarSize;
export type HermesPersonAvatarSize = HermesSize;
6 changes: 6 additions & 0 deletions web/app/types/sizes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export enum HermesSize {
Small = "small",
Medium = "medium",
Large = "large",
XL = "xl",
}

0 comments on commit 6ca7b85

Please sign in to comment.