From fd7af6b1889bed6744e5073650d6dcf5ab833a5f Mon Sep 17 00:00:00 2001 From: PerIngeVaaje Date: Wed, 14 Feb 2024 15:22:31 +0100 Subject: [PATCH 01/16] PXWEB2-34 Added option for icon left and icon right. Added stories. Changed display from inline-felx to flex for .medium class --- .../lib/components/Button/Button.module.scss | 2 +- .../lib/components/Button/Button.stories.tsx | 23 +++++++++++++++++++ .../src/lib/components/Button/Button.tsx | 9 +++++++- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/libs/pxweb2-ui/src/lib/components/Button/Button.module.scss b/libs/pxweb2-ui/src/lib/components/Button/Button.module.scss index ab491da6..5b79b9c5 100644 --- a/libs/pxweb2-ui/src/lib/components/Button/Button.module.scss +++ b/libs/pxweb2-ui/src/lib/components/Button/Button.module.scss @@ -102,7 +102,7 @@ .medium { /* Layout */ - display: inline-flex; + display: flex; padding: 0.75rem 1.25rem; justify-content: center; align-items: center; diff --git a/libs/pxweb2-ui/src/lib/components/Button/Button.stories.tsx b/libs/pxweb2-ui/src/lib/components/Button/Button.stories.tsx index 7b4395f5..63c3f729 100644 --- a/libs/pxweb2-ui/src/lib/components/Button/Button.stories.tsx +++ b/libs/pxweb2-ui/src/lib/components/Button/Button.stories.tsx @@ -127,6 +127,29 @@ export const Variants: StoryFn = () => { onClick={test} aria-label={'Button with icon'} > +
+ Primary icon left +
+ +
+ Primary icon right +
+ +
); }; diff --git a/libs/pxweb2-ui/src/lib/components/Button/Button.tsx b/libs/pxweb2-ui/src/lib/components/Button/Button.tsx index 3cf9746d..6a821273 100644 --- a/libs/pxweb2-ui/src/lib/components/Button/Button.tsx +++ b/libs/pxweb2-ui/src/lib/components/Button/Button.tsx @@ -8,11 +8,13 @@ export interface ButtonProps size?: 'small' | 'medium'; variant: 'primary' | 'secondary' | 'tertiary'; icon?: IconProps['iconName']; + iconPosition?: 'left' | 'right'; children?: string; } export function Button({ icon, + iconPosition = 'left', variant, size = 'medium', children, @@ -25,8 +27,13 @@ export function Button({ })} {...rest} > - {icon && } + {icon && iconPosition === 'left' && ( + + )} {children} + {icon && iconPosition === 'right' && ( + + )} ); } From 43a9136375339004143ac97cdff0efeed6d3d684 Mon Sep 17 00:00:00 2001 From: PerIngeVaaje Date: Thu, 15 Feb 2024 11:22:46 +0100 Subject: [PATCH 02/16] PXWEB2-34 Changed alert message in stories --- libs/pxweb2-ui/src/lib/components/Button/Button.stories.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/pxweb2-ui/src/lib/components/Button/Button.stories.tsx b/libs/pxweb2-ui/src/lib/components/Button/Button.stories.tsx index 63c3f729..f6767008 100644 --- a/libs/pxweb2-ui/src/lib/components/Button/Button.stories.tsx +++ b/libs/pxweb2-ui/src/lib/components/Button/Button.stories.tsx @@ -9,7 +9,7 @@ export default meta; type Story = StoryObj; function test() { - alert('test'); + alert('Button clicked'); } export const ButtonSettings: Story = { From be8ad6a8e82e576ff81b2cda8679c04240148dab Mon Sep 17 00:00:00 2001 From: PerIngeVaaje Date: Thu, 15 Feb 2024 14:36:11 +0100 Subject: [PATCH 03/16] PXWEB2-34 changed icon for icon left and right on button in story --- .../src/lib/components/Button/Button.stories.tsx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/libs/pxweb2-ui/src/lib/components/Button/Button.stories.tsx b/libs/pxweb2-ui/src/lib/components/Button/Button.stories.tsx index f6767008..7c7349d3 100644 --- a/libs/pxweb2-ui/src/lib/components/Button/Button.stories.tsx +++ b/libs/pxweb2-ui/src/lib/components/Button/Button.stories.tsx @@ -130,12 +130,7 @@ export const Variants: StoryFn = () => {
Primary icon left
-
@@ -144,7 +139,7 @@ export const Variants: StoryFn = () => { +
+ Primary icon left +
+ +
+ Primary icon right +
+ +
); }; diff --git a/libs/pxweb2-ui/src/lib/components/Button/Button.tsx b/libs/pxweb2-ui/src/lib/components/Button/Button.tsx index 3cf9746d..6a821273 100644 --- a/libs/pxweb2-ui/src/lib/components/Button/Button.tsx +++ b/libs/pxweb2-ui/src/lib/components/Button/Button.tsx @@ -8,11 +8,13 @@ export interface ButtonProps size?: 'small' | 'medium'; variant: 'primary' | 'secondary' | 'tertiary'; icon?: IconProps['iconName']; + iconPosition?: 'left' | 'right'; children?: string; } export function Button({ icon, + iconPosition = 'left', variant, size = 'medium', children, @@ -25,8 +27,13 @@ export function Button({ })} {...rest} > - {icon && } + {icon && iconPosition === 'left' && ( + + )} {children} + {icon && iconPosition === 'right' && ( + + )} ); } From dacd6fa592710308fb3e2df5a891027cf1139dd1 Mon Sep 17 00:00:00 2001 From: PerIngeVaaje Date: Thu, 15 Feb 2024 11:22:46 +0100 Subject: [PATCH 10/16] PXWEB2-34 Changed alert message in stories --- libs/pxweb2-ui/src/lib/components/Button/Button.stories.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/pxweb2-ui/src/lib/components/Button/Button.stories.tsx b/libs/pxweb2-ui/src/lib/components/Button/Button.stories.tsx index 63c3f729..f6767008 100644 --- a/libs/pxweb2-ui/src/lib/components/Button/Button.stories.tsx +++ b/libs/pxweb2-ui/src/lib/components/Button/Button.stories.tsx @@ -9,7 +9,7 @@ export default meta; type Story = StoryObj; function test() { - alert('test'); + alert('Button clicked'); } export const ButtonSettings: Story = { From 188b0edd856abcba7190bda54bf6794df999815b Mon Sep 17 00:00:00 2001 From: PerIngeVaaje Date: Thu, 15 Feb 2024 14:36:11 +0100 Subject: [PATCH 11/16] PXWEB2-34 changed icon for icon left and right on button in story --- .../src/lib/components/Button/Button.stories.tsx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/libs/pxweb2-ui/src/lib/components/Button/Button.stories.tsx b/libs/pxweb2-ui/src/lib/components/Button/Button.stories.tsx index f6767008..7c7349d3 100644 --- a/libs/pxweb2-ui/src/lib/components/Button/Button.stories.tsx +++ b/libs/pxweb2-ui/src/lib/components/Button/Button.stories.tsx @@ -130,12 +130,7 @@ export const Variants: StoryFn = () => {
Primary icon left
-
@@ -144,7 +139,7 @@ export const Variants: StoryFn = () => {