Skip to content

Commit

Permalink
Small adjustments (#1084)
Browse files Browse the repository at this point in the history
* refactor: small adjustments

* refactor: small adjustments
  • Loading branch information
Lisa18289 authored Dec 18, 2024
1 parent 30b1e1f commit 6991922
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 9 deletions.
6 changes: 5 additions & 1 deletion packages/components/src/components/Avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { getColorFromChildren } from "@/components/Avatar/lib/getColorFromChildr
import type { PropsWithClassName } from "@/lib/types/props";
import type { FlowComponentProps } from "@/lib/componentFactory/flowComponent";
import { flowComponent } from "@/lib/componentFactory/flowComponent";
import { deepHas } from "@/lib/react/deepHas";
import { Initials } from "@/components/Initials";

export const avatarColors = [
"blue",
Expand All @@ -30,11 +32,13 @@ export interface AvatarProps
export const Avatar = flowComponent("Avatar", (props) => {
const { children, className, color, size = "m", refProp: ref } = props;

const hasInitials = deepHas(children, Initials);

const rootClassName = clsx(
styles.avatar,
styles[`size-${size}`],
className,
styles[color ?? getColorFromChildren(children)],
styles[(color ?? hasInitials) ? getColorFromChildren(children) : "blue"],
);

const propsContext: PropsContext = {
Expand Down
9 changes: 8 additions & 1 deletion packages/components/src/components/CopyButton/CopyButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ export interface CopyButtonProps
}

export const CopyButton = flowComponent("CopyButton", (props) => {
const { text, refProp: ref, variant = "plain", ...buttonProps } = props;
const {
text,
refProp: ref,
variant = "plain",
color = "secondary",
...buttonProps
} = props;

const stringFormatter = useLocalizedStringFormatter(locales);

Expand All @@ -39,6 +45,7 @@ export const CopyButton = flowComponent("CopyButton", (props) => {
{...buttonProps}
ref={ref}
variant={variant}
color={color}
>
<IconCopy />
</Button>
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/components/Modal/Modal.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
display: flex;
flex-direction: column;
padding: var(--modal--padding);
min-height: var(--modal--content-min-height);
}

.actionGroup {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { asyncLongFunction } from "@/components/Button/stories/lib";
import { Field, Form } from "@/integrations/react-hook-form";
import { useForm } from "react-hook-form";
import { action } from "@storybook/addon-actions";
import { Section } from "@/components/Section";

const meta: Meta<typeof Modal> = {
title: "Overlays/Modal",
Expand All @@ -38,12 +39,15 @@ const meta: Meta<typeof Modal> = {
>
<Heading>New Customer</Heading>
<Content>
<Text>
Create a new customer to manage your projects, members and payments.
</Text>
<TextField>
<Label>Customer name</Label>
</TextField>
<Section>
<Text>
Create a new customer to manage your projects, members and
payments.
</Text>
<TextField>
<Label>Customer name</Label>
</TextField>
</Section>
</Content>
<ActionGroup>
<Action closeOverlay="Modal">
Expand Down
2 changes: 2 additions & 0 deletions packages/design-tokens/src/overlays/modal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ modal:
value: "{size-px.s}"
off-canvas-max-width:
value: "calc(100dvw - {size-px.m})"
content-min-height:
value: 120px
2 changes: 1 addition & 1 deletion packages/design-tokens/src/structure/section.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ section:
content-to-content-spacing:
value: "{size-rem.m}"
sub-heading-spacing:
value: "{size-rem.s}"
value: "{size-rem.m}"
section-header:
action-to-action-spacing:
value: "{size-rem.s}"
Expand Down

0 comments on commit 6991922

Please sign in to comment.