Skip to content

feat: add resource-action pills to custom roles table #14354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Sep 3, 2024
Prev Previous commit
Next Next commit
chore: undo color roles name change
  • Loading branch information
jaaydenh committed Sep 3, 2024
commit 94975838d1585f5b9a444ae9ad18f3f5d81008cb
2 changes: 1 addition & 1 deletion site/src/components/InfoTooltip/InfoTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
HelpTooltipTrigger,
} from "components/HelpTooltip/HelpTooltip";
import type { FC, ReactNode } from "react";
import type { ThemeRole } from "theme/colorRoles";
import type { ThemeRole } from "theme/roles";

interface InfoTooltipProps {
type?: ThemeRole;
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/Pill/Pill.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
forwardRef,
useMemo,
} from "react";
import type { ThemeRole } from "theme/colorRoles";
import type { ThemeRole } from "theme/roles";

export type PillProps = HTMLAttributes<HTMLDivElement> & {
icon?: ReactNode;
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/StatusIndicator/StatusIndicator.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useTheme } from "@emotion/react";
import type { FC } from "react";
import type { ThemeRole } from "theme/colorRoles";
import type { ThemeRole } from "theme/roles";

interface StatusIndicatorProps {
color: ThemeRole;
Expand Down
2 changes: 1 addition & 1 deletion site/src/pages/AuditPage/AuditLogRow/AuditLogRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { TimelineEntry } from "components/Timeline/TimelineEntry";
import { UserAvatar } from "components/UserAvatar/UserAvatar";
import { type FC, useState } from "react";
import { Link as RouterLink } from "react-router-dom";
import type { ThemeRole } from "theme/colorRoles";
import type { ThemeRole } from "theme/roles";
import userAgentParser from "ua-parser-js";
import { AuditLogDescription } from "./AuditLogDescription/AuditLogDescription";
import { AuditLogDiff } from "./AuditLogDiff/AuditLogDiff";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import QueuedIcon from "@mui/icons-material/HourglassEmpty";
import type { TemplateVersion } from "api/typesGenerated";
import { Pill, PillSpinner } from "components/Pill/Pill";
import type { FC, ReactNode } from "react";
import type { ThemeRole } from "theme/colorRoles";
import type { ThemeRole } from "theme/roles";
import { getPendingStatusLabel } from "utils/provisionerJob";

interface TemplateVersionStatusBadgeProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
usePopover,
} from "components/Popover/Popover";
import type { FC, ReactNode } from "react";
import type { ThemeRole } from "theme/colorRoles";
import type { ThemeRole } from "theme/roles";

export type NotificationItem = {
title: string;
Expand Down
2 changes: 1 addition & 1 deletion site/src/theme/dark/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { forDarkThemes } from "../externalImages";
import roles from "./colorRoles";
import roles from "./roles";
import experimental from "./experimental";
import monaco from "./monaco";
import muiTheme from "./mui";
Expand Down
14 changes: 2 additions & 12 deletions site/src/theme/dark/colorRoles.ts → site/src/theme/dark/roles.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
import type { ColorRoles } from "../colorRoles";
import type { Roles } from "../roles";
import colors from "../tailwindColors";

export default {
default: {
background: colors.zinc[800],
outline: colors.zinc[700],
text: colors.zinc[200],
fill: {
solid: colors.zinc[700],
outline: colors.zinc[600],
text: colors.zinc[50],
},
},
danger: {
background: colors.orange[950],
outline: colors.orange[500],
Expand Down Expand Up @@ -162,4 +152,4 @@ export default {
text: colors.white,
},
},
} satisfies ColorRoles;
} satisfies Roles;
2 changes: 1 addition & 1 deletion site/src/theme/darkBlue/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { forDarkThemes } from "../externalImages";
import roles from "./colorRoles";
import roles from "./roles";
import experimental from "./experimental";
import monaco from "./monaco";
import muiTheme from "./mui";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
import type { ColorRoles } from "../colorRoles";
import type { Roles } from "../roles";
import colors from "../tailwindColors";

export default {
default: {
background: colors.gray[800],
outline: colors.gray[700],
text: colors.gray[200],
fill: {
solid: colors.gray[700],
outline: colors.gray[600],
text: colors.gray[50],
},
},
danger: {
background: colors.orange[950],
outline: colors.orange[500],
Expand Down Expand Up @@ -162,4 +152,4 @@ export default {
text: colors.white,
},
},
} satisfies ColorRoles;
} satisfies Roles;
4 changes: 2 additions & 2 deletions site/src/theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// biome-ignore lint/nursery/noRestrictedImports: We still use `Theme` as a basis for our actual theme, for now.
import type { Theme as MuiTheme } from "@mui/material/styles";
import type * as monaco from "monaco-editor";
import type { ColorRoles } from "./colorRoles";
import type { Roles } from "./roles";
import dark from "./dark";
import darkBlue from "./darkBlue";
import type { NewTheme } from "./experimental";
Expand All @@ -16,7 +16,7 @@ export interface Theme extends Omit<MuiTheme, "palette"> {
* for the user.
* Does it signify an error? a warning? that something is currently running? etc.
*/
roles: ColorRoles;
roles: Roles;

/** Theme properties that we're testing out but haven't committed to. */
experimental: NewTheme;
Expand Down
2 changes: 1 addition & 1 deletion site/src/theme/light/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { forLightThemes } from "../externalImages";
import roles from "./colorRoles";
import roles from "./roles";
import experimental from "./experimental";
import monaco from "./monaco";
import muiTheme from "./mui";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
import type { ColorRoles } from "../colorRoles";
import type { Roles } from "../roles";
import colors from "../tailwindColors";

export default {
default: {
background: colors.zinc[200],
outline: colors.zinc[300],
text: colors.zinc[700],
fill: {
solid: colors.gray[300],
outline: colors.gray[400],
text: colors.gray[800],
},
},
danger: {
background: colors.orange[50],
outline: colors.orange[400],
Expand Down Expand Up @@ -162,4 +152,4 @@ export default {
text: colors.white,
},
},
} satisfies ColorRoles;
} satisfies Roles;
37 changes: 16 additions & 21 deletions site/src/theme/colorRoles.ts → site/src/theme/roles.ts
Original file line number Diff line number Diff line change
@@ -1,54 +1,49 @@
export type ThemeRole = keyof ColorRoles;
export type ThemeRole = keyof Roles;

export type InteractiveThemeRole = keyof {
[K in keyof ColorRoles as ColorRoles[K] extends InteractiveColorRole
? K
: never]: unknown;
[K in keyof Roles as Roles[K] extends InteractiveRole ? K : never]: unknown;
};

export interface ColorRoles {
/** The default color role for general use */
default: ColorRole;

export interface Roles {
/** Something is wrong; either unexpectedly, or in a meaningful way. */
error: ColorRole;
error: Role;

/** Something isn't quite right, but without serious consequence. */
warning: ColorRole;
warning: Role;

/** A prompt for action, to correct or look into something. */
notice: ColorRole;
notice: Role;

/** Notable information; just so you know! */
info: ColorRole;
info: Role;

/** Confirmation, or affirming that things are as desired. */
success: InteractiveColorRole;
success: InteractiveRole;

/** Selected, in progress, of particular relevance right now. */
active: InteractiveColorRole;
active: InteractiveRole;

/** For things that can be made "active", but are not currently so.
* Paused, stopped, off, etc.
*/
inactive: ColorRole;
inactive: Role;

/** Actions that have long lasting or irreversible effects.
* Deletion, immutable parameters, etc.
*/
danger: InteractiveColorRole;
danger: InteractiveRole;

/** This isn't quite ready for prime-time, but you're welcome to look around!
* Preview features, experiments, unstable, etc.
*/
preview: ColorRole;
preview: Role;
}

/**
* A set of colors which work together to fill a desirable "communication role"
* ie. I wish to communicate an error, I wish to communicate that this is dangerous, etc.
*/
export interface ColorRole {
export interface Role {
/** A background color that works best with the corresponding `outline` and `text` colors */
background: string;

Expand All @@ -72,10 +67,10 @@ export interface ColorRole {
}

/** Provides additional colors which can indicate different states for interactive elements */
export interface InteractiveColorRole extends ColorRole {
export interface InteractiveRole extends Role {
/** A set of colors which can indicate a disabled state */
disabled: ColorRole;
disabled: Role;

/** A set of colors which can indicate mouse hover (or keyboard focus) */
hover: ColorRole;
hover: Role;
}