Skip to content
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
6 changes: 6 additions & 0 deletions packages/assets/src/scss/_choice-input-label.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@use './variables' as *;

.ids-choice-input-label {
color: $color-neutral-240;
font-size: $text-font-size-m;
}
1 change: 1 addition & 0 deletions packages/assets/src/scss/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@use 'accordion';
@use 'autosave';
@use 'buttons';
@use 'choice-input-label';
@use 'expander';
@use 'fonts';
@use 'form-control';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React from 'react';

import type { Meta, StoryObj } from '@storybook/react';

import ChoiceInputLabel from './ChoiceInputLabel';

const meta: Meta<typeof ChoiceInputLabel> = {
component: ChoiceInputLabel,
parameters: {
layout: 'centered',
},
tags: ['autodocs'],
argTypes: {
className: {
control: 'text',
},
title: {
control: 'text',
},
},
};

export default meta;

type Story = StoryObj<typeof ChoiceInputLabel>;

export const Default: Story = {
name: 'Default',
args: {
children: 'Lorem Ipsum',
htmlFor: 'default-input',
},
};

export const withHTML: Story = {
name: 'With HTML',
args: {
children: (
<>
<b>Lorem</b>&nbsp;<u>Ipsum</u>
</>
),
htmlFor: 'default-input',
},
};
20 changes: 20 additions & 0 deletions packages/components/src/ChoiceInputLabel/ChoiceInputLabel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';

import { createCssClassNames } from '@ibexa/ids-core/helpers/cssClassNames';

import { ChoiceInputLabelProps } from './ChoiceInputLabel.types';

const ChoiceInputLabel = ({ children, htmlFor, className = '', title = '' }: ChoiceInputLabelProps) => {
const labelClassName = createCssClassNames({
'ids-choice-input-label': true,
[className]: !!className,
});

return (
<label className={labelClassName} htmlFor={htmlFor} title={title}>
{children}
</label>
);
};

export default ChoiceInputLabel;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ReactNode } from 'react';

import { BaseComponentAttributes } from '@ids-types/general';

export interface ChoiceInputLabelProps extends BaseComponentAttributes {
children: ReactNode;
htmlFor: string;
}
5 changes: 5 additions & 0 deletions packages/components/src/ChoiceInputLabel/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import ChoiceInputLabel from './ChoiceInputLabel';
import { ChoiceInputLabelProps } from './ChoiceInputLabel.types';

export default ChoiceInputLabel;
export type { ChoiceInputLabelProps };