Skip to content

Commit

Permalink
Merge 2bb3fd6 into 76b3a65
Browse files Browse the repository at this point in the history
  • Loading branch information
KenAJoh authored May 24, 2023
2 parents 76b3a65 + 2bb3fd6 commit 1298acf
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/silver-mirrors-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@navikt/ds-css": patch
"@navikt/ds-react": patch
---

:bug: Search støtter nå htmlSize-prop
4 changes: 4 additions & 0 deletions @navikt/core/css/form/search.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
width: 100%;
}

.navds-search--with-size :where(.navds-search__wrapper-inner) {
width: inherit;
}

.navds-search__wrapper {
display: inline-flex;
align-items: center;
Expand Down
8 changes: 8 additions & 0 deletions @navikt/core/react/src/form/search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ export interface SearchProps
* @default "primary"
*/
variant?: "primary" | "secondary" | "simple";
/**
* Exposes the HTML size attribute
*/
htmlSize?: number | string;
}

interface SearchComponent
Expand Down Expand Up @@ -112,6 +116,7 @@ export const Search = forwardRef<HTMLInputElement, SearchProps>(
defaultValue,
onChange,
onSearchClick,
htmlSize,
...rest
} = props;

Expand Down Expand Up @@ -164,9 +169,11 @@ export const Search = forwardRef<HTMLInputElement, SearchProps>(
"navds-form-field",
`navds-form-field--${size}`,
"navds-search",

{
"navds-search--error": hasError,
"navds-search--disabled": !!inputProps.disabled,
"navds-search--with-size": !!htmlSize,
}
)}
>
Expand Down Expand Up @@ -215,6 +222,7 @@ export const Search = forwardRef<HTMLInputElement, SearchProps>(
"navds-body-short",
`navds-body-${size}`
)}
{...(htmlSize ? { size: Number(htmlSize) } : {})}
/>
{(value ?? internalValue) && clearButton && (
<button
Expand Down
25 changes: 25 additions & 0 deletions @navikt/core/react/src/form/search/search.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,28 @@ export const NoClearButton = () => (
/>
</div>
);

export const HtmlSize = () => (
<div className="colgap">
<Search
label="Lorem ipsum dolor sit amet"
description="Saepe laborum delectus officia perferendis quaerat excepturi possimus hic enim dicta assumenda."
hideLabel={false}
htmlSize="20"
/>
<Search
label="Lorem ipsum dolor sit amet"
description="Saepe laborum delectus officia perferendis quaerat excepturi possimus hic enim dicta assumenda."
hideLabel={false}
htmlSize="20"
variant="secondary"
/>
<Search
label="Lorem ipsum dolor sit amet"
description="Saepe laborum delectus officia perferendis quaerat excepturi possimus hic enim dicta assumenda."
hideLabel={false}
htmlSize="20"
variant="simple"
/>
</div>
);
2 changes: 1 addition & 1 deletion aksel.nav.no/website/pages/eksempler/search/darkmode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ const Example = () => {
export default withDsExample(Example, "inverted");

export const args = {
index: 6,
index: 7,
};
2 changes: 1 addition & 1 deletion aksel.nav.no/website/pages/eksempler/search/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ export const Demo = {
};

export const args = {
index: 5,
index: 6,
};
26 changes: 26 additions & 0 deletions aksel.nav.no/website/pages/eksempler/search/input-size.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Search } from "@navikt/ds-react";
import { withDsExample } from "components/website-modules/examples/withDsExample";

const Example = () => {
return (
<form>
<Search
label="Hva er artikkelnummeret til denne varen?"
description="Art.nr. finner du på varens produktside eller i katalogen."
hideLabel={false}
htmlSize="12"
/>
</form>
);
};

export default withDsExample(Example);

/* Storybook story */
export const Demo = {
render: Example,
};

export const args = {
index: 5,
};

0 comments on commit 1298acf

Please sign in to comment.