Skip to content

Commit

Permalink
Updated the existing InputLabel story to include an required label.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dresse committed Jul 12, 2024
1 parent 75940ea commit feb31d2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/stories/Library/input-label/InputLabel.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export default {
text: {
defaultValue: "Her er en label",
},
required: {
defaultValue: false,
},
},
parameters: {
layout: "padded",
Expand All @@ -22,3 +25,10 @@ const Template: ComponentStory<DropdownProps> = (args) => (
);

export const InputLabel = Template.bind({});

export const RequiredInputLabel = Template.bind({});

RequiredInputLabel.args = {
text: "Her er en required label",
required: true,
};
6 changes: 4 additions & 2 deletions src/stories/Library/input-label/InputLabel.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
export type InputLabelProps = {
text: string;
required?: boolean;
};

export const InputLabel: React.FC<InputLabelProps> = ({ text }) => {
return <label className="input-label">{text}</label>;
export const InputLabel: React.FC<InputLabelProps> = ({ text, required }) => {
const labelClass = `input-label ${required ? "input-label--required" : ""}`;
return <label className={labelClass}>{text}</label>;
};

0 comments on commit feb31d2

Please sign in to comment.