Skip to content
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

Role editor: hierarchical validation and tabs #49546

Merged
merged 28 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f798c07
Validation
bl-nero Nov 18, 2024
729767d
Move tooltips to the design package
bl-nero Nov 28, 2024
5752c58
SlideTabs improvements
bl-nero Nov 28, 2024
96732fc
Role editor: hierarchical validation and tabs
bl-nero Nov 28, 2024
9810407
Review
bl-nero Nov 28, 2024
8f597d0
Also, rename the tooltip directory
bl-nero Nov 28, 2024
618f0b9
Merge branch 'bl-nero/tooltips' into bl-nero/slidetabs
bl-nero Nov 28, 2024
b10b766
Fix an import
bl-nero Nov 28, 2024
2b2efc8
Merge branch 'bl-nero/slidetabs' into bl-nero/role-editor-7
bl-nero Nov 28, 2024
d4c6ce1
Review: status-related props, extract StatusIcon
bl-nero Dec 2, 2024
382b643
Merge branch 'bl-nero/slidetabs' into bl-nero/role-editor-7
bl-nero Dec 2, 2024
fe8a960
Update after changing the SlideTabs interface
bl-nero Dec 2, 2024
0f803c3
Also, rename the tooltip component
bl-nero Dec 2, 2024
cbda4b7
Merge branch 'bl-nero/tooltips' into bl-nero/slidetabs
bl-nero Dec 2, 2024
2a0a9d4
Merge branch 'bl-nero/slidetabs' into bl-nero/role-editor-7
bl-nero Dec 2, 2024
22be016
review
bl-nero Dec 3, 2024
afd0cf3
Merge branch 'bl-nero/validation' into bl-nero/tooltips
bl-nero Dec 3, 2024
e3eda32
Merge branch 'bl-nero/tooltips' into bl-nero/slidetabs
bl-nero Dec 3, 2024
4aa406c
review
bl-nero Dec 3, 2024
f420534
Merge branch 'bl-nero/slidetabs' into bl-nero/role-editor-7
bl-nero Dec 3, 2024
17823aa
REview
bl-nero Dec 3, 2024
1df3878
Merge branch 'master' into bl-nero/validation
bl-nero Dec 4, 2024
5e020d9
Never return undefined from useValidation()
bl-nero Dec 4, 2024
4392381
Merge branch 'bl-nero/validation' into bl-nero/tooltips
bl-nero Dec 4, 2024
e805224
Merge branch 'bl-nero/tooltips' into bl-nero/slidetabs
bl-nero Dec 4, 2024
d358ee7
Merge branch 'bl-nero/slidetabs' into bl-nero/role-editor-7
bl-nero Dec 4, 2024
9e19f60
Merge branch 'master' into bl-nero/slidetabs
bl-nero Dec 5, 2024
968b7cb
Merge branch 'bl-nero/slidetabs' into bl-nero/role-editor-7
bl-nero Dec 5, 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
61 changes: 29 additions & 32 deletions web/packages/design/src/Alert/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import { style, color, ColorProps } from 'styled-system';

import { IconProps } from 'design/Icon/Icon';

import { StatusIcon, StatusKind } from 'design/StatusIcon';

import { space, SpaceProps, width, WidthProps } from '../system';
import { Theme } from '../theme';
import * as Icon from '../Icon';
Expand Down Expand Up @@ -193,7 +195,12 @@ export const Alert = ({
<OuterContainer bg={bg} kind={kind} {...otherProps}>
<InnerContainer kind={kind}>
<IconContainer kind={kind}>
<AlertIcon kind={kind} customIcon={icon} size={alertIconSize} />
<StatusIcon
kind={iconKind(kind)}
customIcon={icon}
size={alertIconSize}
color="inherit"
/>
</IconContainer>
<Box
flex="1"
Expand Down Expand Up @@ -249,36 +256,6 @@ const InnerContainer = styled.div<AlertPropsWithRequiredKind>`
${backgroundColor}
`;

const AlertIcon = ({
kind,
customIcon: CustomIcon,
...otherProps
}: {
kind: AlertKind | BannerKind;
customIcon?: React.ComponentType<IconProps>;
} & IconProps) => {
const commonProps = { role: 'graphics-symbol', ...otherProps };
if (CustomIcon) {
return <CustomIcon {...commonProps} />;
}
switch (kind) {
case 'success':
return <Icon.Checks aria-label="Success" {...commonProps} />;
case 'danger':
case 'outline-danger':
return <Icon.WarningCircle aria-label="Danger" {...commonProps} />;
case 'info':
case 'outline-info':
return <Icon.Info aria-label="Info" {...commonProps} />;
case 'warning':
case 'outline-warn':
return <Icon.Warning aria-label="Warning" {...commonProps} />;
case 'neutral':
case 'primary':
return <Icon.Notification aria-label="Note" {...commonProps} />;
}
};

const iconContainerStyles = ({
kind,
theme,
Expand Down Expand Up @@ -468,7 +445,12 @@ export const Banner = ({
gap={3}
alignItems="center"
>
<AlertIcon kind={kind} customIcon={icon} size="large" color={iconColor} />
<StatusIcon
kind={iconKind(kind)}
customIcon={icon}
size="large"
color={iconColor}
/>
<Box flex="1">
<Text typography="h3">{children}</Text>
{details}
Expand Down Expand Up @@ -525,3 +507,18 @@ const bannerColors = (theme: Theme, kind: BannerKind) => {
};
}
};

const iconKind = (kind: AlertKind | BannerKind): StatusKind => {
switch (kind) {
case 'outline-danger':
return 'danger';
case 'outline-warn':
return 'warning';
case 'outline-info':
return 'info';
case 'primary':
return 'neutral';
default:
return kind;
}
};
65 changes: 54 additions & 11 deletions web/packages/design/src/SlideTabs/SlideTabs.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import React, { useState } from 'react';
import * as Icon from 'design/Icon';
import Flex from 'design/Flex';

import { SlideTabs } from './SlideTabs';
import { SlideTabs, TabSpec } from './SlideTabs';

export default {
title: 'Design/SlideTabs',
Expand Down Expand Up @@ -120,9 +120,33 @@ export const Small = () => {
<Flex flexDirection="column" gap={3}>
<SlideTabs
tabs={[
{ key: 'alarm', icon: Icon.AlarmRing, ariaLabel: 'alarm' },
{ key: 'bots', icon: Icon.Bots, ariaLabel: 'bots' },
{ key: 'check', icon: Icon.Check, ariaLabel: 'check' },
{
key: 'alarm',
icon: Icon.AlarmRing,
ariaLabel: 'alarm',
tooltip: {
content: 'ring ring',
position: 'bottom',
},
},
{
key: 'bots',
icon: Icon.Bots,
ariaLabel: 'bots',
tooltip: {
content: 'beep boop',
position: 'bottom',
},
},
{
key: 'check',
icon: Icon.Check,
ariaLabel: 'check',
tooltip: {
content: 'Do or do not. There is no try.',
position: 'right',
},
},
]}
size="small"
appearance="round"
Expand Down Expand Up @@ -154,14 +178,33 @@ export const Small = () => {
);
};

export const LoadingTab = () => {
export const StatusIcons = () => {
const [activeIndex, setActiveIndex] = useState(0);
const tabs: TabSpec[] = [
{ key: 'warning', title: 'warning', status: { kind: 'warning' } },
{ key: 'danger', title: 'danger', status: { kind: 'danger' } },
{ key: 'neutral', title: 'neutral', status: { kind: 'neutral' } },
];
return (
<SlideTabs
tabs={threeSimpleTabs}
onChange={() => null}
activeIndex={1}
isProcessing={true}
/>
<Flex flexDirection="column" gap={3}>
<SlideTabs
tabs={tabs}
activeIndex={activeIndex}
onChange={setActiveIndex}
isProcessing={true}
/>
<SlideTabs
tabs={tabs}
activeIndex={activeIndex}
onChange={setActiveIndex}
/>
<SlideTabs
tabs={tabs}
hideStatusIconOnActiveTab
activeIndex={activeIndex}
onChange={setActiveIndex}
/>
</Flex>
);
};

Expand Down
9 changes: 8 additions & 1 deletion web/packages/design/src/SlideTabs/SlideTabs.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import { screen } from '@testing-library/react';

import { render, userEvent } from 'design/utils/testing';

import * as Icon from 'design/Icon';

import { SlideTabs, SlideTabsProps } from './SlideTabs';

describe('design/SlideTabs', () => {
Expand Down Expand Up @@ -87,7 +89,12 @@ describe('design/SlideTabs', () => {
<Component
tabs={[
{ key: 'id1', title: 'first', controls: 'tabpanel-1' },
{ key: 'id2', title: 'second', controls: 'tabpanel-2' },
{
key: 'id2',
icon: Icon.Check,
ariaLabel: 'second',
controls: 'tabpanel-2',
},
]}
/>
);
Expand Down
Loading
Loading