Skip to content

Commit e5de5a4

Browse files
committed
💄(frontend) create IconBG component
Create IconBG component, a premade Icon component with a background color.
1 parent c2d6e60 commit e5de5a4

File tree

4 files changed

+51
-38
lines changed

4 files changed

+51
-38
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { Text, TextType } from '@/components';
2+
import { useCunninghamTheme } from '@/cunningham';
3+
4+
interface IconBGProps extends TextType {
5+
iconName: string;
6+
}
7+
8+
export const IconBG = ({ iconName, ...textProps }: IconBGProps) => {
9+
const { colorsTokens } = useCunninghamTheme();
10+
11+
return (
12+
<Text
13+
$isMaterialIcon
14+
$size="36px"
15+
$theme="primary"
16+
$background={colorsTokens()['primary-bg']}
17+
$css={`border: 1px solid ${colorsTokens()['primary-200']}`}
18+
$radius="12px"
19+
$padding="4px"
20+
$margin="auto"
21+
{...textProps}
22+
>
23+
{iconName}
24+
</Text>
25+
);
26+
};
27+
28+
interface IconOptionsProps {
29+
isOpen: boolean;
30+
'aria-label': string;
31+
}
32+
33+
export const IconOptions = ({ isOpen, ...props }: IconOptionsProps) => {
34+
return (
35+
<Text
36+
aria-label={props['aria-label']}
37+
$isMaterialIcon
38+
$css={`
39+
transition: all 0.3s ease-in-out;
40+
transform: rotate(${isOpen ? '90' : '0'}deg);
41+
`}
42+
>
43+
more_vert
44+
</Text>
45+
);
46+
};

src/frontend/apps/impress/src/components/IconOptions.tsx

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/frontend/apps/impress/src/components/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ export * from './Box';
22
export * from './BoxButton';
33
export * from './Card';
44
export * from './DropButton';
5-
export * from './IconOptions';
5+
export * from './Icon';
6+
export * from './InfiniteScroll';
67
export * from './Link';
78
export * from './Text';
89
export * from './TextErrors';

src/frontend/apps/impress/src/features/docs/members/members-add/components/AddMembers.tsx

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import { useState } from 'react';
77
import { useTranslation } from 'react-i18next';
88

99
import { APIError } from '@/api';
10-
import { Box, Card, Text } from '@/components';
11-
import { useCunninghamTheme } from '@/cunningham';
10+
import { Box, Card, IconBG } from '@/components';
1211
import { Doc, Role } from '@/features/docs/doc-management';
1312

1413
import { useCreateDocAccess, useCreateInvitation } from '../api';
@@ -35,7 +34,6 @@ interface ModalAddMembersProps {
3534

3635
export const AddMembers = ({ currentRole, doc }: ModalAddMembersProps) => {
3736
const { t } = useTranslation();
38-
const { colorsTokens } = useCunninghamTheme();
3937
const [selectedUsers, setSelectedUsers] = useState<OptionsSelect>([]);
4038
const [selectedRole, setSelectedRole] = useState<Role>();
4139
const { toast } = useToastProvider();
@@ -126,23 +124,12 @@ export const AddMembers = ({ currentRole, doc }: ModalAddMembersProps) => {
126124
<Card
127125
$gap="1rem"
128126
$padding="1rem"
129-
$margin="1rem 0.7rem"
127+
$margin="tiny"
130128
$direction="row"
131129
$align="center"
132130
$wrap="wrap"
133131
>
134-
<Text
135-
$isMaterialIcon
136-
$size="44px"
137-
$theme="primary"
138-
$background={colorsTokens()['primary-bg']}
139-
$css={`border: 1px solid ${colorsTokens()['primary-200']}`}
140-
$radius="12px"
141-
$padding="4px"
142-
$margin="auto"
143-
>
144-
group_add
145-
</Text>
132+
<IconBG iconName="group_add" />
146133
<Box $gap="0.7rem" $direction="row" $wrap="wrap" $css="flex: 70%;">
147134
<Box $gap="0.7rem" $direction="row" $wrap="wrap" $css="flex: 80%;">
148135
<Box $css="flex: auto;">

0 commit comments

Comments
 (0)