Skip to content

Commit

Permalink
Add a story to base component in pxweb2-ui
Browse files Browse the repository at this point in the history
Adds a basic story to the current base component in pxweb2-ui.

Per Inge Vaaje <[email protected]>
Mikael Nordberg
  • Loading branch information
SjurSutterudSagen committed Jan 17, 2024
1 parent 28a1c29 commit e6a897d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
5 changes: 4 additions & 1 deletion apps/pxweb2/src/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ export function App() {
return (
<div>
<NxWelcome title="pxweb2" />
<Pxweb2Ui />
<Pxweb2Ui
title="Welcome to pxweb2-ui!"
variant="primary"
/>
</div>
);
}
Expand Down
16 changes: 15 additions & 1 deletion libs/pxweb2-ui/src/lib/pxweb2-ui.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,21 @@ export default meta;
type Story = StoryObj<typeof Pxweb2Ui>;

export const Primary = {
args: {},
args: {
title: 'pxweb2-ui primary!',
variant: 'primary',
},
};

export const Secondary: Story = {
args: {
title: 'pxweb2-ui secondary!',
variant: 'secondary',
},
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
expect(canvas.getByText(/pxweb2-ui secondary!/gi)).toBeTruthy();
},
};

export const Heading: Story = {
Expand Down
12 changes: 10 additions & 2 deletions libs/pxweb2-ui/src/lib/pxweb2-ui.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import styles from './pxweb2-ui.module.scss';

/* eslint-disable-next-line */
export interface Pxweb2UiProps {}
export interface Pxweb2UiProps {
title: string;
variant: 'primary' | 'secondary';
}

export function Pxweb2Ui(props: Pxweb2UiProps) {
const title = props.title || 'Welcome to pxweb2-ui!';

return (
<div className={styles['container']}>
<h1>Welcome to Pxweb2Ui! Hei alle sammen</h1>
<h1>{title}</h1>
{props.variant === 'primary' && (
<button className={styles['button']}>Primary</button>
)}
</div>
);
}
Expand Down

0 comments on commit e6a897d

Please sign in to comment.