Skip to content

Commit

Permalink
chore: Replace static IconProps.Name with import from components pack…
Browse files Browse the repository at this point in the history
…age (#18)

* chore: Update avatar ariaLabel description

* chore: Replace static IconProps.Name with import from components package

* chore: Pass node module paths to documenter

* fix: Remove added script

* chore: Replace cwd with path.resolve
  • Loading branch information
cansuaa authored Aug 9, 2024
1 parent 69154d2 commit d3287e2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 108 deletions.
13 changes: 12 additions & 1 deletion scripts/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { dashCase, listPublicDirs, writeSourceFile } from "./utils.js";
const publicDirs = listPublicDirs("src");
const targetDir = "lib/components/internal/api-docs";

const importedCoreComponents = ["icon"];

componentDocs();
testUtilDocs();

Expand All @@ -20,8 +22,17 @@ function validatePublicFiles(definitionFiles) {
}
}

function getNodeModulesInterfacePath(componentName) {
return path.resolve("node_modules/@cloudscape-design/components", componentName, "interfaces.d.ts");
}

function componentDocs() {
const definitions = documentComponents(path.resolve("tsconfig.json"), "src/*/index.tsx");
const nodeModulesDependencyFilePaths = importedCoreComponents.map(getNodeModulesInterfacePath);
const definitions = documentComponents(
path.resolve("tsconfig.json"),
"src/*/index.tsx",
nodeModulesDependencyFilePaths,
);
const outDir = path.join(targetDir, "components");
const fileNames = definitions
.filter((definition) => {
Expand Down
108 changes: 1 addition & 107 deletions src/avatar/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { IconProps } from "@cloudscape-design/components/icon";

export interface AvatarProps {
/**
Expand Down Expand Up @@ -64,110 +65,3 @@ export interface AvatarProps {
export namespace AvatarProps {
export type Color = "default" | "gen-ai";
}

// This is added here because cross package reference doesn't work in documenter and icon names are not populated
// It'll be replaced by documenter implementation once documenter is updated to handle cross package reference
namespace IconProps {
// Why not enums? Explained there
// https://stackoverflow.com/questions/52393730/typescript-string-literal-union-type-from-enum
export type Name =
| "add-plus"
| "anchor-link"
| "angle-left-double"
| "angle-left"
| "angle-right-double"
| "angle-right"
| "angle-up"
| "angle-down"
| "arrow-left"
| "arrow-right"
| "audio-full"
| "audio-half"
| "audio-off"
| "bug"
| "call"
| "calendar"
| "caret-down-filled"
| "caret-down"
| "caret-left-filled"
| "caret-right-filled"
| "caret-up-filled"
| "caret-up"
| "check"
| "contact"
| "close"
| "copy"
| "delete-marker"
| "download"
| "drag-indicator"
| "edit"
| "ellipsis"
| "envelope"
| "expand"
| "external"
| "file-open"
| "file"
| "filter"
| "flag"
| "folder-open"
| "folder"
| "gen-ai"
| "group-active"
| "group"
| "heart"
| "heart-filled"
| "insert-row"
| "key"
| "keyboard"
| "lock-private"
| "menu"
| "microphone"
| "microphone-off"
| "multiscreen"
| "notification"
| "redo"
| "refresh"
| "remove"
| "resize-area"
| "script"
| "search"
| "security"
| "settings"
| "send"
| "share"
| "shrink"
| "star-filled"
| "star-half"
| "star"
| "status-in-progress"
| "status-info"
| "status-negative"
| "status-pending"
| "status-positive"
| "status-stopped"
| "status-warning"
| "subtract-minus"
| "suggestions"
| "thumbs-down-filled"
| "thumbs-down"
| "thumbs-up-filled"
| "thumbs-up"
| "ticket"
| "treeview-collapse"
| "treeview-expand"
| "undo"
| "unlocked"
| "upload-download"
| "upload"
| "user-profile-active"
| "user-profile"
| "video-off"
| "video-on"
| "video-unavailable"
| "view-full"
| "view-horizontal"
| "view-vertical"
| "zoom-in"
| "zoom-out"
| "zoom-to-fit";
}

0 comments on commit d3287e2

Please sign in to comment.