Skip to content

Commit

Permalink
reduce unnecessary classnames
Browse files Browse the repository at this point in the history
  • Loading branch information
Lisa18289 committed Jan 19, 2024
1 parent dbc568e commit 59c53d0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 31 deletions.

This file was deleted.

3 changes: 1 addition & 2 deletions packages/components/src/components/CopyButton/CopyButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Icon } from "@/components/Icon";
import { faCopy } from "@fortawesome/free-regular-svg-icons/faCopy";
import locales from "./locales/*.locale.json";
import { useLocalizedStringFormatter } from "react-aria";
import styles from "./CopyButton.module.css";
import clsx from "clsx";

export interface CopyButtonProps {
Expand All @@ -19,7 +18,7 @@ export const CopyButton: FC<CopyButtonProps> = (props) => {

const stringFormatter = useLocalizedStringFormatter(locales);

const rootClassName = clsx(className, styles.root);
const rootClassName = clsx(className);

const ariaLabel = stringFormatter.format("copyButton.copy");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@
column-gap: var(--labeled-value--value-to-copy-button-spacing);
width: fit-content;

&:has(.copyButton) {
&:has(> :global(.flow-button)) {
grid-template-areas:
"label label"
"value copyButton";
"value button";
}
}

.label {
grid-area: label;
}
:global(.flow-label) {
grid-area: label;
}

.value {
grid-area: value;
}
:global(.flow-text) {
grid-area: value;
}

.copyButton {
grid-area: copyButton;
margin-top: calc(var(--labeled-value--label-to-value-spacing) * -1);
align-self: start;
& > :global(.flow-button) {
grid-area: button;
margin-top: calc(var(--labeled-value--label-to-value-spacing) * -1);
align-self: start;
}
}
15 changes: 3 additions & 12 deletions packages/components/src/components/LabeledValue/LabeledValue.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { FC, PropsWithChildren, ReactNode } from "react";
import { PropsContext, PropsContextProvider } from "@/lib/propsContext";
import styles from "./LabeledValue.module.css";
import clsx from "clsx";
import { Text } from "@/components/Text";
Expand All @@ -16,19 +15,11 @@ export const LabeledValue: FC<LabeledValueProps> = (props) => {

const rootClassName = clsx(className, styles.root);

const propsContext: PropsContext = {
Label: {
className: styles.label,
},
};

return (
<div className={rootClassName}>
<PropsContextProvider props={propsContext}>
{children}
<Text>{value}</Text>
{copyable && <CopyButton className={styles.copyButton} value={value} />}
</PropsContextProvider>
{children}
<Text>{value}</Text>
{copyable && <CopyButton value={value} />}
</div>
);
};
Expand Down

0 comments on commit 59c53d0

Please sign in to comment.