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

feat: support base styles for UnstyledButton #743

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/hot-ants-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@easypost/easy-ui": minor
---

feat: support base styles for internal UnstyledButton component
1 change: 0 additions & 1 deletion easy-ui-react/src/Button/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
}

@mixin variantFilled {
border: 0;
background-color: component-token("button", "resting.color");
color: component-token("button", "filled.font.color");

Expand Down
6 changes: 0 additions & 6 deletions easy-ui-react/src/CodeBlock/LanguageMenu.module.scss

This file was deleted.

4 changes: 1 addition & 3 deletions easy-ui-react/src/CodeBlock/LanguageMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import { Menu } from "../Menu";
import { Text } from "../Text";
import { UnstyledButton } from "../UnstyledButton";

import styles from "./LanguageMenu.module.scss";

export type LanguageMenuProps = {
/**
* List of languages.
Expand Down Expand Up @@ -41,7 +39,7 @@ export function LanguageMenu(props: LanguageMenuProps) {
return (
<Menu>
<Menu.Trigger>
<UnstyledButton className={styles.button}>
<UnstyledButton>
<HorizontalStack blockAlign="center" gap="1" wrap={false}>
<Text variant="body1">
{friendlySnippetLanguageNames[language]}
Expand Down
1 change: 0 additions & 1 deletion easy-ui-react/src/InputField/InputField.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
border: design-token("shape.border_width.1") solid
component-token("inputfield", "color.border.resting");
border-left: none;
margin: 0;
padding: calc(
#{design-token("space.1.5")} - #{design-token("shape.border_width.1")}
);
Expand Down
1 change: 0 additions & 1 deletion easy-ui-react/src/Notification/Notification.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
}

.closeButton {
border: 0;
padding: design-token("space.0");
/* prettier-ignore */
margin: design-token("space.0.5") design-token("space.1") design-token("space.0.5") design-token("space.2");
Expand Down
2 changes: 0 additions & 2 deletions easy-ui-react/src/ProductLayout/HelpMenu.module.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
@use "../styles/common" as *;
@use "../styles/unstyled";

.button {
@include unstyled.button;
display: inline-flex;
cursor: pointer;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@use "../styles/common" as *;
@use "../styles/unstyled";
@use "mixins" as ProductLayout;

.ProductLayoutHeader {
Expand Down Expand Up @@ -28,7 +27,6 @@
}

.logoMenuBtn {
@include unstyled.button;
display: inline-flex;
cursor: pointer;
}
Expand Down
2 changes: 0 additions & 2 deletions easy-ui-react/src/SearchNav/CTAGroup.module.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@use "../styles/common" as *;
@use "../styles/unstyled";

.ctaGroup {
@include component-token("cta-group", "max-height", 24px);
Expand Down Expand Up @@ -30,6 +29,5 @@
}

.menuBtn {
@include unstyled.button;
color: component-token("cta-group", "menu-color");
}
2 changes: 0 additions & 2 deletions easy-ui-react/src/SearchNav/CTAItem.module.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
@use "../styles/common" as *;
@use "../styles/unstyled";

.cta {
@include unstyled.button;
@include component-token("cta", "color", theme-token("color.text"));
display: flex;
align-items: center;
Expand Down
2 changes: 0 additions & 2 deletions easy-ui-react/src/SearchNav/CondensedSearchNav.module.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@use "../styles/common" as *;
@use "../styles/unstyled";

.condensed {
display: flex;
Expand Down Expand Up @@ -28,7 +27,6 @@
"search-color",
theme-token("color.text")
);
@include unstyled.button;
}

.menuBtn {
Expand Down
2 changes: 0 additions & 2 deletions easy-ui-react/src/SearchNav/SelectorTrigger.module.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
@use "../styles/common" as *;
@use "../styles/unstyled";

.triggerBtn {
@include component-token(
"selector-trigger",
"color",
theme-token("color.selector")
);
@include unstyled.button;
@include font-style("subtitle1");
display: flex;
align-items: center;
Expand Down
2 changes: 0 additions & 2 deletions easy-ui-react/src/Stepper/StepButton.module.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@use "../styles/common" as *;
@use "../styles/unstyled";

.containerHorizontal {
@include component-token("step-button", "max-height", 56px);
Expand Down Expand Up @@ -76,7 +75,6 @@

.StepButton {
@include font-style("subtitle1");
@include unstyled.button;
display: flex;
align-items: center;
gap: design-token("space.1");
Expand Down
10 changes: 10 additions & 0 deletions easy-ui-react/src/UnstyledButton/UnstyledButton.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.UnstyledButton {
appearance: none;
margin: 0;
padding: 0;
background: none;
border: 0;
font-size: inherit;
line-height: inherit;
color: inherit;
}
10 changes: 10 additions & 0 deletions easy-ui-react/src/UnstyledButton/UnstyledButton.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,14 @@ describe("<UnstyledButton />", () => {
render(<UnstyledButton isDisabled />);
expect(screen.getByRole("button")).toBeDisabled();
});

it("should apply the default class", () => {
render(
<UnstyledButton className="colorPrimary_123">Button</UnstyledButton>,
);
expect(screen.getByRole("button")).toHaveAttribute(
"class",
expect.stringContaining("UnstyledButton"),
);
});
});
4 changes: 3 additions & 1 deletion easy-ui-react/src/UnstyledButton/UnstyledButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { AriaButtonProps, mergeProps, useButton } from "react-aria";
import { classNames } from "../utilities/css";
import { omitReactAriaSpecificProps } from "../Button/utilities";

import styles from "./UnstyledButton.module.scss";

export type UnstyledButtonProps = AriaButtonProps<"button"> & {
/* Classname to apply styles to button */
className?: string;
Expand Down Expand Up @@ -52,7 +54,7 @@ export const UnstyledButton = forwardRef<null, UnstyledButtonProps>(
{...mergeProps(omitReactAriaSpecificProps(restProps), elementProps)}
disabled={isDisabled}
ref={mergeRefs(ref, inRef)}
className={classNames(className)}
className={classNames(styles.UnstyledButton, className)}
>
{children}
</As>
Expand Down