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 StudioTag and StudioBetaTag #13639

Merged
merged 5 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';
import type { Meta, StoryFn } from '@storybook/react';
import { StudioBetaTag } from './StudioBetaTag';

type Story = StoryFn<typeof StudioBetaTag>;

const meta: Meta = {
title: 'Components/StudioBetaTag',
component: StudioBetaTag,
argTypes: {
size: {
control: 'radio',
options: ['sm', 'md', 'lg'],
},
},
};

export const Preview: Story = (args): React.ReactElement => <StudioBetaTag {...args} />;

Preview.args = {
size: 'sm',
};

export default meta;
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import { StudioBetaTag, type StudioBetaTagProps } from './StudioBetaTag';
import { testRootClassNameAppending } from '../../test-utils/testRootClassNameAppending';

describe('StudioBetaTag', () => {
it('should render the "Beta" text', () => {
renderStudioBetaTag();
expect(screen.getByText('Beta')).toBeInTheDocument();
});

it('Appends given classname to the component', () => {
testRootClassNameAppending((className) => renderStudioBetaTag({ className }));
framitdavid marked this conversation as resolved.
Show resolved Hide resolved
});
});

const renderStudioBetaTag = (props: Partial<StudioBetaTagProps> = {}) => {
return render(<StudioBetaTag {...props} />);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import { StudioTag, type StudioTagProps } from '../StudioTag';

export type StudioBetaTagProps = Omit<StudioTagProps, 'color' | 'children'>;

export const StudioBetaTag = ({ size = 'sm', ...rest }: StudioBetaTagProps) => {
return (
<StudioTag color='info' size={size} {...rest}>
Beta
</StudioTag>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { StudioBetaTag, type StudioBetaTagProps } from './StudioBetaTag';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Tag as StudioTag, type TagProps as StudioTagProps } from '@digdir/designsystemet-react';
2 changes: 2 additions & 0 deletions frontend/libs/studio-components/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './StudioAnimateHeight';
export * from './StudioBetaTag';
export * from './StudioBlobDownloader';
export * from './StudioBooleanToggleGroup';
export * from './StudioButton';
Expand Down Expand Up @@ -35,6 +36,7 @@ export * from './StudioCombobox';
export * from './StudioTableLocalPagination';
export * from './StudioTableRemotePagination';
export * from './StudioTabs';
export * from './StudioTag';
export * from './StudioTextarea';
export * from './StudioTextfield';
export * from './StudioToggleableTextfield';
Expand Down