mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-07 15:03:20 -04:00
chore(ui-components): rename HelpBlock files to kebab-case (#45849)
This commit is contained in:
25
tools/ui-components/src/help-block/help-block.stories.tsx
Normal file
25
tools/ui-components/src/help-block/help-block.stories.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import React from 'react';
|
||||
import { Story } from '@storybook/react';
|
||||
import { HelpBlock } from './help-block';
|
||||
import { HelpBlockProps } from './types';
|
||||
|
||||
const story = {
|
||||
title: 'Example/HelpBlock',
|
||||
component: HelpBlock,
|
||||
parameters: {
|
||||
controls: {
|
||||
include: ['className', 'children']
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const Template: Story<HelpBlockProps> = args => {
|
||||
return <HelpBlock {...args} />;
|
||||
};
|
||||
|
||||
export const Default = Template.bind({});
|
||||
Default.args = {
|
||||
children: 'This is a HelpBlock'
|
||||
};
|
||||
|
||||
export default story;
|
||||
14
tools/ui-components/src/help-block/help-block.test.tsx
Normal file
14
tools/ui-components/src/help-block/help-block.test.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
import { HelpBlock } from './help-block';
|
||||
|
||||
describe('Render the helpblock component', () => {
|
||||
it('should render the helpblock component', () => {
|
||||
render(<HelpBlock />);
|
||||
expect(screen.getByTestId('help-block')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('help-block')).toHaveClass(
|
||||
'block mt-1 mb-2 text-default-foreground-quaternary',
|
||||
{ exact: true }
|
||||
);
|
||||
});
|
||||
});
|
||||
16
tools/ui-components/src/help-block/help-block.tsx
Normal file
16
tools/ui-components/src/help-block/help-block.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
import React from 'react';
|
||||
import { HelpBlockProps } from './types';
|
||||
|
||||
export const HelpBlock = React.forwardRef<HTMLSpanElement, HelpBlockProps>(
|
||||
({ className, children }, ref): JSX.Element => {
|
||||
const defaultClasses = 'block mt-1 mb-2 text-default-foreground-quaternary';
|
||||
const classes = [defaultClasses, className].join(' ');
|
||||
return (
|
||||
<span ref={ref} data-testid='help-block' className={classes}>
|
||||
{children}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
HelpBlock.displayName = 'HelpBlock';
|
||||
2
tools/ui-components/src/help-block/index.ts
Normal file
2
tools/ui-components/src/help-block/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export { HelpBlock } from './help-block';
|
||||
export type { HelpBlockProps } from './types';
|
||||
4
tools/ui-components/src/help-block/types.ts
Normal file
4
tools/ui-components/src/help-block/types.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export interface HelpBlockProps {
|
||||
className?: string;
|
||||
children?: React.ReactNode;
|
||||
}
|
||||
Reference in New Issue
Block a user