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

fix: button primitive component normalization #949

Merged
merged 9 commits into from
Jan 30, 2023
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
70 changes: 31 additions & 39 deletions frontend/src/components/Board/AddCardOrComment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@ import UpdateCommentDto from '@/types/comment/updateComment.dto';
import { styled } from '@/styles/stitches/stitches.config';
import Icon from '../icons/Icon';

const ActionButton = styled(Button, {
padding: '$10 $14 !important',

svg: {
width: '$16',
height: '$16',
},
});

const StyledForm = styled('form', Flex, { width: '100%' });

type AddCardProps = {
Expand Down Expand Up @@ -175,7 +166,6 @@ const AddCard = React.memo<AddCardProps>(
css={{
mx: '$20',
display: 'flex',
fontWeight: '$medium',
}}
onClick={() => setIsOpen(true)}
>
Expand Down Expand Up @@ -218,18 +208,18 @@ const AddCard = React.memo<AddCardProps>(
id="text"
placeholder={!isDefaultText ? placeholder : 'Write your comment here...'}
/>
{!isCard && (
<Checkbox
id={colId + cardId}
label="Add anonymously"
size="16"
checked={anonymous}
setCheckedTerms={() => {
setIsCommentAnonymous(!isCommentAnonymous);
}}
/>
)}
<Flex css={{ width: '100%' }} gap="4" justify="end">
<Flex css={{ width: '100%' }} justify="end">
{!isCard && (
<Checkbox
id={colId + cardId}
label="Add anonymously"
size="16"
checked={anonymous}
setCheckedTerms={() => {
setIsCommentAnonymous(!isCommentAnonymous);
}}
/>
)}
{!isEditing && (
<Checkbox
id={colId}
Expand All @@ -241,23 +231,25 @@ const AddCard = React.memo<AddCardProps>(
}}
/>
)}
<ActionButton
css={{ width: '$48', height: '$36' }}
size="sm"
variant={!isUpdate && isCard ? 'lightOutline' : 'primaryOutline'}
onClick={handleClear}
>
<Icon name="close" />
</ActionButton>
<ActionButton
css={{ width: '$48', height: '$36' }}
disabled={disabledButton}
size="sm"
type="submit"
variant="primary"
>
<Icon name="check" />
</ActionButton>
<Flex gap="8">
<Button
css={{ width: '$52', height: '$36' }}
size="sm"
variant={!isUpdate && isCard ? 'lightOutline' : 'primaryOutline'}
onClick={handleClear}
>
<Icon name="close" />
</Button>
<Button
css={{ width: '$52', height: '$36' }}
disabled={disabledButton}
size="sm"
type="submit"
variant="primary"
>
<Icon name="check" />
</Button>
</Flex>
</Flex>
</FormProvider>
</StyledForm>
Expand Down
50 changes: 18 additions & 32 deletions frontend/src/components/Board/Card/CardFooter.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React, { useEffect, useMemo, useState } from 'react';

import { styled } from '@/styles/stitches/stitches.config';

import Icon from '@/components/icons/Icon';
import Avatar from '@/components/Primitives/Avatar';
import Button from '@/components/Primitives/Button';
Expand Down Expand Up @@ -31,30 +29,6 @@ interface FooterProps {
hideCards: boolean;
}

const StyledButtonIcon = styled(Button, {
m: '0 !important',
p: '0 !important',
lineHeight: '0 !important',
height: 'fit-content !important',
backgroundColor: 'transparent !important',
'& svg': {
color: '$primary500',
},
'@hover': {
'&:hover': {
backgroundColor: 'transparent !important',
},
},
'&:active': {
boxShadow: 'none !important',
},
'&:disabled': {
svg: {
opacity: '0.2',
},
},
});

const CardFooter = ({
boardId,
userId,
Expand Down Expand Up @@ -206,7 +180,11 @@ const CardFooter = ({
filter: cardFooterBlur(hideCards, createdBy, userId),
}}
>
<StyledButtonIcon
<Button
isIcon
variant="light"
size="sm"
css={{ color: '$primary500' }}
disabled={
!isMainboard ||
(maxVotes && user?.votesCount === maxVotes) ||
Expand All @@ -215,7 +193,7 @@ const CardFooter = ({
onClick={handleAddVote}
>
<Icon name="thumbs-up" />
</StyledButtonIcon>
</Button>
<Text
size="xs"
css={{
Expand All @@ -235,7 +213,11 @@ const CardFooter = ({
filter: cardFooterBlur(hideCards, createdBy, userId),
}}
>
<StyledButtonIcon
<Button
isIcon
variant="light"
size="sm"
css={{ color: '$primary500' }}
disabled={
!isMainboard ||
votesInThisCard.length === 0 ||
Expand All @@ -246,7 +228,7 @@ const CardFooter = ({
onClick={handleDeleteVote}
>
<Icon name="thumbs-down" />
</StyledButtonIcon>
</Button>
</Flex>

<Flex
Expand All @@ -256,12 +238,16 @@ const CardFooter = ({
filter: cardFooterBlur(hideCards, createdBy, userId),
}}
>
<StyledButtonIcon
<Button
isIcon
variant="light"
size="sm"
css={{ color: '$primary500' }}
disabled={hideCards && createdBy?._id !== userId}
onClick={setOpenComments}
>
<Icon name={isCommentsOpened ? 'comment-filled' : 'comment'} />
</StyledButtonIcon>
</Button>
<Text css={{ visibility: comments.length > 0 ? 'visible' : 'hidden' }} size="xs">
{comments.length}
</Text>
Expand Down
13 changes: 9 additions & 4 deletions frontend/src/components/Board/Settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import isEmpty from '@/utils/isEmpty';
import Dialog from '@/components/Primitives/Dialog';
import { styled } from '@/styles/stitches/stitches.config';
import { ScrollableContent } from '@/components/Boards/MyBoards/ListBoardMembers/styles';
import Button from '@/components/Primitives/Button';
import ColumnType, { CreateColumn } from '@/types/column';
import { ConfigurationSwitchSettings } from './partials/ConfigurationSettings/ConfigurationSwitch';
import { ConfigurationSettings } from './partials/ConfigurationSettings';
import { TeamResponsibleSettings } from './partials/TeamResponsible';
import { ColumnBoxAndDelete } from './partials/Columns/ColumnBoxAndDelete';
import { ColumnSettings } from './partials/Columns';
import { AddColumnButton } from './partials/Columns/AddColumnButton';
import { colors } from '../Column/partials/OptionsMenu';

const DEFAULT_MAX_VOTES = 6;
Expand Down Expand Up @@ -531,9 +531,14 @@ const BoardSettings = ({
disableDeleteColumn={editColumns.length === 1}
/>
))}
{editColumns.length < 4 && (
<AddColumnButton onAddColumn={handleAddColumn} />
)}
<Flex direction="row" justify="start">
{editColumns.length < 4 && (
<Button variant="link" size="sm" onClick={handleAddColumn}>
<Icon name="plus" />
Add new column
</Button>
)}
</Flex>
</Flex>
</ColumnSettings>
)}
Expand Down

This file was deleted.

14 changes: 0 additions & 14 deletions frontend/src/components/Board/Settings/styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import * as DialogPrimitive from '@radix-ui/react-dialog';
import { keyframes, styled } from '@/styles/stitches/stitches.config';

import Icon from '@/components/icons/Icon';
import Button from '@/components/Primitives/Button';
import Flex from '@/components/Primitives/Flex';

/**
Expand Down Expand Up @@ -71,18 +70,6 @@ const StyledDialogTitle = styled('div', DialogPrimitive.Title, {
},
});

const StyledDialogCloseButton = styled(Button, {
color: '$primary400',
height: '40px !important',
padding: '10px !important',

transition: 'all 0.25s ease-in-out',

'&:hover': {
backgroundColor: '$primary50 !important',
},
});

/**
* Accordion Animations
*/
Expand Down Expand Up @@ -205,7 +192,6 @@ export {
StyledAccordionIcon,
StyledAccordionItem,
StyledAccordionTrigger,
StyledDialogCloseButton,
StyledDialogContainer,
StyledDialogContent,
StyledDialogOverlay,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Icon from '@/components/icons/Icon';
import AlertCustomDialog from '@/components/Primitives/AlertCustomDialog';
import { AlertDialogTrigger } from '@/components/Primitives/AlertDialog';
import Button from '@/components/Primitives/Button';
Expand All @@ -23,15 +24,9 @@ const AlertMergeIntoMain: React.FC<Props> = ({ boardId, socketId }) => {
}}
>
<AlertDialogTrigger asChild>
<Button
size="sm"
variant="primaryOutline"
css={{
fontWeight: '$medium',
width: '$206',
}}
>
<Button size="sm" variant="primaryOutline">
Merge into main board
<Icon name="merge" />
</Button>
</AlertDialogTrigger>
</AlertCustomDialog>
Expand Down
8 changes: 3 additions & 5 deletions frontend/src/components/Boards/Filters/FilterBoards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@ export interface OptionType {
}

const StyledButton = styled(Button, {
border: '1px solid $colors$primary100',
border: '1px solid $primary100',
borderRadius: '0px',
height: '$36 !important',
backgroundColor: '$white !important',
color: '$primary300 !important',
fontSize: '$14 !important',
lineHeight: '$20 !important',
fontWeight: '$medium !important',
'&[data-active="true"]': {
borderColor: '$primary800',
color: '$primary800 !important',
Expand All @@ -38,13 +34,15 @@ const FilterBoards: React.FC<FilterBoardsProps> = ({ teamNames }) => {
return (
<Flex css={{ zIndex: '10' }} justify="end">
<StyledButton
size="sm"
css={{ borderRadius: '12px 0 0 12px' }}
data-active={filterState === 'all'}
onClick={() => setFilterState('all')}
>
All
</StyledButton>
<StyledButton
size="sm"
data-active={filterState === 'personal'}
onClick={() => setFilterState('personal')}
>
Expand Down
Loading