Skip to content

feat: create UI badges for labeling beta features #14661

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 48 commits into from
Sep 20, 2024
Merged

Conversation

Parkreiner
Copy link
Member

@Parkreiner Parkreiner commented Sep 12, 2024

Closes #14499

Changes made

  • Added general FeatureStageBadge component for labeling components that are beta/experimental
  • Added component to Organizations features
  • Updated Popover component to support sending events outside the component

Bonus

  • Updated a few styles surrounding the existing orgs work
    • Updated the colors for the organizations navbar so that they have better contrast in dark mode
    • Updated letter tracking for the navbar header
    • Updated the header for the Provisioners page so that it matches all the other pages
    • Updated some spacing values in general

Notes

  • @aslilac Tagging you for the review because the PR does change how the Preview role is set up

@Parkreiner Parkreiner self-assigned this Sep 12, 2024
@Parkreiner Parkreiner requested a review from aslilac September 18, 2024 16:45
@@ -1,10 +1,12 @@
import MuiPopover, {
type PopoverProps as MuiPopoverProps,
// biome-ignore lint/nursery/noRestrictedImports: Used as base component
// biome-ignore lint/nursery/noRestrictedImports: This is the base component that our custom popover is based on
Copy link
Member Author

Choose a reason for hiding this comment

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

I might have Biome configured wrong because my Biome plugin is flagging all of these comments as not doing anything

Accidentally removed this at first, but that's definitely a me problem, right?

Copy link
Member

Choose a reason for hiding this comment

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

I think it doesn't like that our biome.json config is in the site/ directory 🙄 I hate that extensions never bother to handle subdirectories well.

{title}
</h1>
{tooltip}
<Stack direction="row" spacing={2} alignItems="center">
Copy link
Member Author

Choose a reason for hiding this comment

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

Only change is that the previous content is in a new stack so that the badges can be placed inside them

@@ -149,7 +149,7 @@ const styles = {
menuItem: (theme) => css`
text-decoration: none;
color: inherit;
gap: 20px;
gap: 8px;
Copy link
Member Author

Choose a reason for hiding this comment

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

This was a change from when the feature badges were still part of the dropdown. Even with that removed, though, the gap seemed way too big for any feature elements we add

@@ -396,7 +412,7 @@ const classNames = {
`,

subLink: (css, theme) => css`
color: inherit;
color: ${theme.palette.text.secondary};
Copy link
Member Author

Choose a reason for hiding this comment

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

De-emphasized the colors of the inactive sub links because in dark mode, there wasn't enough contrast to make it obvious which subheader was active

Copy link
Member

@aslilac aslilac left a comment

Choose a reason for hiding this comment

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

I'm not sure I'm sold on why preview needs to become an InteractiveRole, that's a lot of extra colors to manage for a badge that never uses the disabled variants (and I don't get why it needs hover either. we don't modify the colors of any other UI elements just because they have a tooltip.)

@@ -1,10 +1,12 @@
import MuiPopover, {
type PopoverProps as MuiPopoverProps,
// biome-ignore lint/nursery/noRestrictedImports: Used as base component
// biome-ignore lint/nursery/noRestrictedImports: This is the base component that our custom popover is based on
Copy link
Member

Choose a reason for hiding this comment

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

I think it doesn't like that our biome.json config is in the site/ directory 🙄 I hate that extensions never bother to handle subdirectories well.

@Parkreiner Parkreiner changed the title feat: add UI badges for labeling beta features feat: create UI badges for labeling beta features Sep 20, 2024
@@ -1,7 +1,7 @@
import type { Branding } from "../branding";
import colors from "../tailwindColors";

export default {
Copy link
Member Author

Choose a reason for hiding this comment

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

Forgot to leave a comment on these earlier, but the reason why I switched the syntax from satisfies to type annotations is because when I was adding additional properties to the type definitions, satisfies wasn't always immediately kicking up an error when something was only partially updated, and it made way more red squiggles than it needed to

Comment on lines 96 to 110
{({ isOpen }) => (
<span
css={[
styles.badge,
size === "sm" && styles.badgeSmallText,
size === "lg" && styles.badgeLargeText,
isOpen && styles.badgeHover,
]}
{...delegatedProps}
>
<span style={visuallyHidden}> (This is a</span>
{featureStageBadgeTypes[contentType]}
<span style={visuallyHidden}> feature)</span>
</span>
)}
Copy link
Member Author

Choose a reason for hiding this comment

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

Ended up using render props to cut down the repetitive state

Comment on lines 81 to 86
type FeatureStageBadgeProps = Readonly<
Omit<HTMLAttributes<HTMLSpanElement>, "children"> & {
contentType: keyof typeof featureStageBadgeTypes;
size?: "sm" | "md" | "lg";
}
>;
Copy link
Member Author

Choose a reason for hiding this comment

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

Ended up applying YAGNI to the props and removed pretty much everything that isn't part of the current requirements. We have no need for a static version of the component right now

@Parkreiner Parkreiner requested a review from aslilac September 20, 2024 03:31
experimental: "experimental",
} as const satisfies Record<string, ReactNode>;

const styles = {
Copy link
Member

Choose a reason for hiding this comment

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

I think we generally define styles below the component

@Parkreiner Parkreiner enabled auto-merge (squash) September 20, 2024 21:08
@Parkreiner Parkreiner merged commit 661d226 into main Sep 20, 2024
27 checks passed
@Parkreiner Parkreiner deleted the mes/beta-badges branch September 20, 2024 21:13
@github-actions github-actions bot locked and limited conversation to collaborators Sep 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UI: add beta labels to Organization feature
2 participants