Skip to content

Commit 1ca47af

Browse files
committed
Refactor Button component: remove showLabelWithLoading prop, update test descriptions, and enhance shimmer effect for loading state
1 parent 781940a commit 1ca47af

File tree

3 files changed

+8
-22
lines changed

3 files changed

+8
-22
lines changed

src/components/Button/Button.stories.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,5 @@ export const Playground: Story = {
1919
align: "center",
2020
fillWidth: false,
2121
loading: false,
22-
showLabelWithLoading: false,
2322
},
2423
};

src/components/Button/Button.test.tsx

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe("Button", () => {
2424
expect(counter).toEqual(1);
2525
});
2626

27-
it("given a loading button, it should render the loading icon", async () => {
27+
it("given a loading button, it should render the loading animation", async () => {
2828
const { getAllByTestId } = renderButton({
2929
label: "Button",
3030
loading: true,
@@ -34,19 +34,7 @@ describe("Button", () => {
3434
expect(loadingButton.length).toEqual(1);
3535
});
3636

37-
it("given a loading button and showLabelWithLoading, it should render the loading icon and the label", async () => {
38-
const { getAllByTestId, getByTestId } = renderButton({
39-
label: "Button",
40-
loading: true,
41-
showLabelWithLoading: true,
42-
});
43-
44-
const loadingButton = getAllByTestId("click-ui-loading-icon");
45-
expect(loadingButton.length).toEqual(1);
46-
expect(getByTestId("click-ui-loading-icon-wrapper")).toHaveTextContent("Button");
47-
});
48-
49-
it("given a non-loading button, it should not render the loading icon", async () => {
37+
it("given a non-loading button, it should not render the loading animation", async () => {
5038
const { queryAllByTestId } = renderButton({
5139
label: "Button",
5240
loading: false,

src/components/Button/Button.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ export const Button = ({
7171

7272
const shimmer = keyframes`
7373
0% {
74-
background-position: -200px 0;
74+
background-position: 100% 0;
7575
}
7676
100% {
77-
background-position: 200px 0;
77+
background-position: -100% 0;
7878
}
7979
`;
8080

@@ -108,27 +108,26 @@ const StyledButton = styled(BaseButton)<{
108108
right: 0;
109109
bottom: 0;
110110
pointer-events: none;
111-
background-size: 200px 100%;
111+
background-size: 200% 100%;
112112
opacity: 0;
113113
}
114114
115115
${({ $loading, $styleType, theme }) => {
116116
if (!$loading) return "";
117117
118-
// Create dynamic shimmer gradient using the button's background colors
119-
const bgDefault = "rgba(255, 255, 255, 0)";
120118
const bgHover = theme.click.button.basic.color[$styleType].background.hover;
121119
122120
const shimmerGradient = `linear-gradient(
123121
90deg,
124122
${bgHover} 0%,
125-
${theme.global.color.background.default} 50%,
123+
transparent 50%,
126124
${bgHover} 100%
127125
)`;
128126
129127
return css`
130128
&::before {
131-
background: ${shimmerGradient} 0% 0% / 50% 100% no-repeat;
129+
background: ${shimmerGradient};
130+
background-size: 200% 100%;
132131
animation: ${shimmer} 1.5s ease-in-out infinite;
133132
opacity: 1;
134133
}

0 commit comments

Comments
 (0)