-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move general form elemnts out in their own scopes
and use the design system components instead of replicating the html in the webforms story
- Loading branch information
Showing
11 changed files
with
238 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { FC, ReactNode } from "react"; | ||
Check warning on line 1 in src/stories/Library/Forms/label/Label.tsx GitHub Actions / JS Linter
|
||
|
||
export interface LabelProps { | ||
id: string; | ||
children: string; | ||
className?: string; | ||
} | ||
|
||
const Label: FC<LabelProps> = ({ id, className, children }) => ( | ||
<label htmlFor={id} {...(className ? { className } : {})}> | ||
{children} | ||
</label> | ||
); | ||
|
||
export default Label; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { ComponentStory, ComponentMeta } from "@storybook/react"; | ||
import { withDesign } from "storybook-addon-designs"; | ||
import Textarea from "./Textarea"; | ||
|
||
export default { | ||
title: "Library / Forms / Textarea", | ||
component: Textarea, | ||
decorators: [withDesign], | ||
argTypes: { | ||
id: { | ||
defaultValue: "id", | ||
}, | ||
name: { | ||
defaultValue: "name", | ||
}, | ||
label: { | ||
defaultValue: "Besked", | ||
}, | ||
}, | ||
parameters: { | ||
design: { | ||
type: "figma", | ||
url: "https://www.figma.com/file/xouARmJCONbzbZhpD8XpcM/Brugerprofil?node-id=1239%3A66174", | ||
}, | ||
layout: "padded", | ||
}, | ||
} as ComponentMeta<typeof Textarea>; | ||
|
||
const Template: ComponentStory<typeof Textarea> = (args) => ( | ||
<Textarea {...args} /> | ||
); | ||
|
||
export const Default = Template.bind({}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { FC } from "react"; | ||
import Label from "../label/Label"; | ||
|
||
export interface TextareaProps { | ||
id: string; | ||
name: string; | ||
label: string; | ||
rows?: number; | ||
cols?: number; | ||
} | ||
|
||
const Textarea: FC<TextareaProps> = ({ | ||
id, | ||
name, | ||
label, | ||
rows = 8, | ||
cols = 80, | ||
}) => { | ||
return ( | ||
<div className="dpl-input"> | ||
<Label id={id}>{label}</Label> | ||
<div> | ||
<textarea id={id} name={name} rows={rows} cols={cols} /> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Textarea; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.dpl-input { | ||
&:has(.form-textarea) { | ||
max-width: $block-max-width__medium; | ||
} | ||
|
||
& textarea { | ||
@include typography($typo__body-placeholder); | ||
border: solid 1px $color__global-tertiary-1; | ||
width: 100%; | ||
padding: $s-md; | ||
resize: none; | ||
background-color: $color__global-primary; | ||
|
||
@extend %default-focus-visible; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.