Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add StudioSearch component #14348

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jeg ser at det er gjort på denne måten enkelte andre steder, men for å følge fasademønsteret, bør vi egentlig lage en egen komponent rundt designsystemkomponenten. Da kan vi også sette size='sm' som standard og ta i bruk WithoutAsChild på prop-typen.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export {
Search as StudioSearch,
type SearchProps as StudioSearchProps,
} from '@digdir/designsystemet-react';
1 change: 1 addition & 0 deletions frontend/libs/studio-components/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export * from './StudioProperty';
export * from './StudioRecommendedNextAction';
export * from './StudioRedirectBox';
export * from './StudioResizableLayout';
export * from './StudioSearch';
export * from './StudioSectionHeader';
export * from './StudioSpinner';
export * from './StudioSwitch';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import { Search } from '@digdir/designsystemet-react';
import { StudioFileUploader } from '@studio/components';
import { StudioFileUploader, StudioSearch } from '@studio/components';
import classes from './CodeListsActionsBar.module.css';
import { useTranslation } from 'react-i18next';
import type { CodeListWithMetadata } from '../CodeListPage';
Expand Down Expand Up @@ -36,7 +35,7 @@ export function CodeListsActionsBar({

return (
<div className={classes.actionsBar}>
<Search
<StudioSearch
className={classes.searchField}
size='sm'
placeholder={t('app_content_library.code_lists.search_placeholder')}
Expand Down
2 changes: 1 addition & 1 deletion frontend/packages/text-editor/src/TextEditor.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
.filterAndSearch {
display: flex;
flex-direction: row;
align-items: flex-end;
align-items: center;
gap: 1rem;
}

Expand Down
4 changes: 2 additions & 2 deletions frontend/packages/text-editor/src/TextEditor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ describe('TextEditor', () => {
renderTextEditor({});

const textEntries = screen.getAllByRole('textbox');
expect(textEntries[1]).toHaveValue(textValue1);
expect(textEntries[0]).toHaveValue(textValue1);

const sortAlphabeticallyButton = screen.getByText(textMock('text_editor.sort_alphabetically'));
await user.click(sortAlphabeticallyButton);

const sortedTranslations = screen.getAllByRole('textbox');
expect(sortedTranslations[1]).toHaveValue(textValue2);
expect(sortedTranslations[0]).toHaveValue(textValue2);
TomasEng marked this conversation as resolved.
Show resolved Hide resolved
});

it('signals correctly when a translation is changed', async () => {
Expand Down
9 changes: 4 additions & 5 deletions frontend/packages/text-editor/src/TextEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import React, { useEffect, useMemo, useRef, useState } from 'react';
import classes from './TextEditor.module.css';
import type { LangCode, TextResourceEntryDeletion, TextResourceIdMutation } from './types';
import type { UpsertTextResourceMutation } from 'app-shared/hooks/mutations/useUpsertTextResourceMutation';
import { SearchField } from '@altinn/altinn-design-system';
TomasEng marked this conversation as resolved.
Show resolved Hide resolved
import { Chip } from '@digdir/designsystemet-react';
import { ArrowsUpDownIcon } from '@studio/icons';
import { StudioButton } from '@studio/components';
import { StudioButton, StudioSearch } from '@studio/components';
import { RightMenu } from './RightMenu';
import { getRandNumber, mapResourceFilesToTableRows } from './utils';
import { defaultLangCode } from './constants';
Expand Down Expand Up @@ -108,9 +107,9 @@ export const TextEditor = ({
}
</Chip.Toggle>
<div>
<SearchField
id='text-editor-search'
label={t('text_editor.search_for_text')}
<StudioSearch
size='small'
placeholder={t('text_editor.search_for_text')}
TomasEng marked this conversation as resolved.
Show resolved Hide resolved
value={searchQuery}
onChange={handleSearchChange}
/>
Expand Down
Loading