Skip to content

Commit

Permalink
Merge branch 'master' into field-spacing-review
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeltaranto authored Jul 29, 2024
2 parents 882c2cb + 71e819f commit a560ad6
Show file tree
Hide file tree
Showing 11 changed files with 160 additions and 27 deletions.
15 changes: 15 additions & 0 deletions .changeset/calm-owls-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
'braid-design-system': minor
---

---
new:
- IconHash
---

**IconHash:** Add component

**EXAMPLE USAGE:**
```jsx
<IconHash />
```
13 changes: 13 additions & 0 deletions .changeset/perfect-rockets-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'braid-design-system': patch
---

---
updated:
- Badge
---

**Badge:** Ensure label follows correct tone

Ensure that the foreground text of a `Badge` always follows the correct tone for the background colour.
Fixes a bug where using a `Badge` in a `List` that overrides the default tone would result in the `Badge` text following the `List` tone instead of the `Badge` tone.
1 change: 1 addition & 0 deletions packages/braid-design-system/icons/hash.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/braid-design-system/scripts/generateIcons.cts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ const svgrConfig = {
const docs: ComponentDocs = {
category: 'Icon',
Example: () =>
Example: () =>
source(
<Stack space="none" align="center">
<Heading component="div" level="1">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import type { ComponentScreenshot } from 'site/types';
import { Badge, Inline, Heading } from '../';
import { Badge, Inline, Heading, List } from '../';

export const screenshots: ComponentScreenshot = {
screenshotWidths: [320],
Expand Down Expand Up @@ -108,5 +108,16 @@ export const screenshots: ComponentScreenshot = {
</Badge>
),
},
{
label: 'Test: Badge text should follow tone not default set by `List`',
Example: () => (
<List tone="secondary">
<Badge tone="critical">Critical</Badge>
<Badge tone="critical" weight="strong">
Critical
</Badge>
</List>
),
},
],
};
55 changes: 30 additions & 25 deletions packages/braid-design-system/src/lib/components/Badge/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import buildDataAttributes, {
type DataAttributeMap,
} from '../private/buildDataAttributes';
import { Bleed } from '../Bleed/Bleed';
import { DefaultTextPropsProvider } from '../private/defaultTextProps';

type ValueOrArray<T> = T | T[];

Expand Down Expand Up @@ -83,35 +84,39 @@ export const Badge = forwardRef<HTMLSpanElement, BadgeProps>(
);

const content = (
<Box
component="span"
display="flex"
cursor="default"
{...buildDataAttributes({ data, validateRestProps: restProps })}
>
// Ensures the foreground text tone follows the default
// for the selected background colour
<DefaultTextPropsProvider tone="neutral">
<Box
component="span"
id={id}
ref={ref}
tabIndex={tabIndex}
aria-describedby={ariaDescribedBy}
title={
title ??
(!ariaDescribedBy ? stringifyChildren(children) : undefined)
}
background={
weight === 'strong' ? tone : lightModeBackgroundForTone[tone]
}
paddingY={verticalPadding}
paddingX="xsmall"
borderRadius="standard"
overflow="hidden"
display="flex"
cursor="default"
{...buildDataAttributes({ data, validateRestProps: restProps })}
>
<Text size="xsmall" weight="medium" maxLines={1}>
{children}
</Text>
<Box
component="span"
id={id}
ref={ref}
tabIndex={tabIndex}
aria-describedby={ariaDescribedBy}
title={
title ??
(!ariaDescribedBy ? stringifyChildren(children) : undefined)
}
background={
weight === 'strong' ? tone : lightModeBackgroundForTone[tone]
}
paddingY={verticalPadding}
paddingX="xsmall"
borderRadius="standard"
overflow="hidden"
>
<Text size="xsmall" weight="medium" maxLines={1}>
{children}
</Text>
</Box>
</Box>
</Box>
</DefaultTextPropsProvider>
);

return bleedY ? (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';
import type { ComponentDocs } from 'site/types';
import { iconDocumentation } from '../iconCommon.docs';
import source from '@braid-design-system/source.macro';
import { IconHash, Heading, Stack } from '../../';

const docs: ComponentDocs = {
category: 'Icon',
Example: () =>
source(
<Stack space="none" align="center">
<Heading component="div" level="1">
<IconHash />
</Heading>
</Stack>,
),
alternatives: [],
additional: [iconDocumentation],
};

export default docs;
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import { Box } from '../../Box/Box';
import useIcon, { type UseIconProps } from '../../../hooks/useIcon';
import { IconHashSvg } from './IconHashSvg';

export type IconHashProps = UseIconProps;

export const IconHash = (props: IconHashProps) => {
const iconProps = useIcon(props);

return <Box component={IconHashSvg} {...iconProps} />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,29 @@ export const IconGridSvg = ({ title, titleId, ...props }: SVGProps) => (
"
`;

exports[`IconHashSvg should match snapshot 1`] = `
"import React from 'react';
import type { SVGProps } from '../SVGTypes';
export const IconHashSvg = ({ title, titleId, ...props }: SVGProps) => (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
focusable="false"
fill="currentColor"
width={16}
height={16}
aria-labelledby={titleId}
{...props}
>
{title ? <title id={titleId}>{title}</title> : null}
<path d="M20 14h-4.216l.445-4H20a1 1 0 1 0 0-2h-3.55l.544-4.89a1.001 1.001 0 0 0-.884-1.104 1.014 1.014 0 0 0-1.104.884L14.438 8h-3.987l.543-4.89a1.001 1.001 0 0 0-.884-1.104c-.536-.05-1.044.335-1.104.884L8.438 8H4a1 1 0 1 0 0 2h4.216l-.445 4H4a1 1 0 1 0 0 2h3.55l-.544 4.89a1.001 1.001 0 0 0 1.988.22L9.562 16h3.987l-.543 4.89a1.001 1.001 0 0 0 1.988.22l.568-5.11H20a1 1 0 1 0 0-2ZM9.784 14l.445-4h3.987l-.445 4H9.784Z" />
</svg>
);
"
`;

exports[`IconHeartActiveSvg should match snapshot 1`] = `
"import React from 'react';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export { IconFlag } from './IconFlag/IconFlag';
export { IconGift } from './IconGift/IconGift';
export { IconGlobe } from './IconGlobe/IconGlobe';
export { IconGrid } from './IconGrid/IconGrid';
export { IconHash } from './IconHash/IconHash';
export { IconHeart } from './IconHeart/IconHeart';
export { IconHelp } from './IconHelp/IconHelp';
export { IconHistory } from './IconHistory/IconHistory';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4371,6 +4371,37 @@ exports[`IconGrid 1`] = `
}
`;

exports[`IconHash 1`] = `
{
exportType: component,
props: {
alignY?:
| "lowercase"
| "uppercase"
data?: DataAttributeMap
size?:
| "fill"
| "large"
| "small"
| "standard"
| "xsmall"
title?: string
titleId?: string
tone?:
| "brandAccent"
| "caution"
| "critical"
| "formAccent"
| "info"
| "link"
| "neutral"
| "positive"
| "promote"
| "secondary"
},
}
`;

exports[`IconHeart 1`] = `
{
exportType: component,
Expand Down

0 comments on commit a560ad6

Please sign in to comment.