Skip to content

Commit d6c9c76

Browse files
committed
feat: org text component
1 parent 4d52291 commit d6c9c76

File tree

4 files changed

+79
-1
lines changed

4 files changed

+79
-1
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@beeinventor/dasiot-react-component-lib",
3-
"version": "1.4.2",
3+
"version": "1.5.0",
44
"module": "lib/index.js",
55
"types": "lib/index.d.ts",
66
"files": [
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React from 'react';
2+
import { Meta, Story } from '@storybook/react';
3+
4+
import OrgText, { OrgTextProps } from '.';
5+
6+
export default {
7+
title: 'Components/OrgText',
8+
component: OrgText,
9+
argTypes: {},
10+
parameters: {
11+
backgrounds: { default: 'light' },
12+
},
13+
} as Meta;
14+
15+
const Template: Story<OrgTextProps> = (args) => <OrgText {...args} />;
16+
17+
export const Default: Story<OrgTextProps> = Template.bind({});
18+
19+
Default.args = {
20+
orgName: 'BeeInventor',
21+
};
22+
23+
export const SpecificColor: Story<OrgTextProps> = Template.bind({});
24+
25+
SpecificColor.args = {
26+
...Default.args,
27+
orgColor: '#58B99E',
28+
};

src/components/OrgText/index.tsx

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { styled, Box, BoxProps } from '@mui/material';
2+
import React from 'react';
3+
4+
interface ContainerProps {
5+
orgColor: string | undefined;
6+
}
7+
8+
const shouldForwardProp = (propName: PropertyKey) => propName !== 'orgColor';
9+
const Container = styled(Box, { shouldForwardProp })<ContainerProps>`
10+
display: inline-flex;
11+
align-items: center;
12+
font-size: 1rem;
13+
line-height: 1.5;
14+
font-weight: 500;
15+
color: ${({ theme }) => theme.color.secondary.$100};
16+
padding: 4px 15px 4px 0;
17+
18+
& > span.org-name {
19+
&::before {
20+
display: inline-block;
21+
content: '';
22+
width: 6px;
23+
height: 0.875rem;
24+
background-color: ${({ theme, orgColor }) =>
25+
orgColor ? orgColor : theme.color.primary.$100};
26+
border-radius: 3px;
27+
margin-right: 8px;
28+
}
29+
}
30+
`;
31+
32+
export interface OrgTextProps extends BoxProps {
33+
orgColor: string | undefined;
34+
orgName: string;
35+
}
36+
37+
const OrgText: React.FC<OrgTextProps> = ({
38+
orgColor,
39+
orgName,
40+
...otherProps
41+
}) => {
42+
return (
43+
<Container orgColor={orgColor} {...otherProps}>
44+
<span className="org-name">{orgName}</span>
45+
</Container>
46+
);
47+
};
48+
49+
export default OrgText;

src/components/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ export { default as DropdownColor } from './Dropdown/DropdownColor';
1010
export { default as DatePicker } from './DatePicker';
1111
export { default as Step } from './Step';
1212
export { default as SearchTextField } from './SearchTextField';
13+
export { default as OrgText } from './OrgText';

0 commit comments

Comments
 (0)