Skip to content

Commit

Permalink
Merge pull request #681 from danskernesdigitalebibliotek/DDFLSBP-659-…
Browse files Browse the repository at this point in the history
…add-visual-indicators-on-required-fields

DDFLSBP-659 - Add visual indicators on required fields
  • Loading branch information
Dresse authored Sep 2, 2024
2 parents eb1c696 + 2ca37f8 commit 5d8b068
Show file tree
Hide file tree
Showing 3 changed files with 18 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>;
};
4 changes: 4 additions & 0 deletions src/stories/Library/input-label/input-label.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
margin-bottom: $s-sm;
padding-top: $s-xs;
}

.input-label--required::after {
content: " *";
}

0 comments on commit 5d8b068

Please sign in to comment.