From beedf58e43d20712d039bc10e96b3260d5cf55db Mon Sep 17 00:00:00 2001 From: WRadoslaw <92513933+WRadoslaw@users.noreply.github.com> Date: Tue, 22 Aug 2023 13:02:17 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=98=84=20Benefit=20list=20item=20(#4644)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * UI work * Add logic to single input * Disable move button on borders * Create multiple benefit input * Create story for multiple benefit input * Build fix * CR --- .../BenefitInput/BenefitInput.stories.tsx | 18 +++++++ .../BenefitInput/BenefitInput.styles.ts | 51 ++++++++++++++++++ .../_inputs/BenefitInput/BenefitInput.tsx | 53 +++++++++++++++++++ .../components/_inputs/BenefitInput/index.ts | 1 + .../BenefitsInput/BenefitsInput.stories.tsx | 15 ++++++ .../_inputs/BenefitsInput/BenefitsInput.tsx | 53 +++++++++++++++++++ .../components/_inputs/BenefitsInput/index.ts | 1 + 7 files changed, 192 insertions(+) create mode 100644 packages/atlas/src/components/_inputs/BenefitInput/BenefitInput.stories.tsx create mode 100644 packages/atlas/src/components/_inputs/BenefitInput/BenefitInput.styles.ts create mode 100644 packages/atlas/src/components/_inputs/BenefitInput/BenefitInput.tsx create mode 100644 packages/atlas/src/components/_inputs/BenefitInput/index.ts create mode 100644 packages/atlas/src/components/_inputs/BenefitsInput/BenefitsInput.stories.tsx create mode 100644 packages/atlas/src/components/_inputs/BenefitsInput/BenefitsInput.tsx create mode 100644 packages/atlas/src/components/_inputs/BenefitsInput/index.ts diff --git a/packages/atlas/src/components/_inputs/BenefitInput/BenefitInput.stories.tsx b/packages/atlas/src/components/_inputs/BenefitInput/BenefitInput.stories.tsx new file mode 100644 index 0000000000..3bc6bd0ee8 --- /dev/null +++ b/packages/atlas/src/components/_inputs/BenefitInput/BenefitInput.stories.tsx @@ -0,0 +1,18 @@ +import { Meta, StoryFn } from '@storybook/react' + +import { BenefitInput, BenefitInputProps } from './BenefitInput' + +export default { + title: 'inputs/BenefitInput', + component: BenefitInput, +} as Meta + +const Template: StoryFn = (args: BenefitInputProps) => + +export const Default = Template.bind({}) +Default.bind({ + onMoveUp: () => undefined, + onMoveDown: () => undefined, + onRemove: () => undefined, + position: 'middle', +}) diff --git a/packages/atlas/src/components/_inputs/BenefitInput/BenefitInput.styles.ts b/packages/atlas/src/components/_inputs/BenefitInput/BenefitInput.styles.ts new file mode 100644 index 0000000000..479307351c --- /dev/null +++ b/packages/atlas/src/components/_inputs/BenefitInput/BenefitInput.styles.ts @@ -0,0 +1,51 @@ +import styled from '@emotion/styled' + +import { SvgActionTrash } from '@/assets/icons' +import { cVar, media, sizes } from '@/styles' + +export const Container = styled.div` + display: grid; + grid-template-columns: 1fr 1fr; + gap: ${sizes(2)}; + + > *:nth-child(2) { + grid-column: 1/3; + } + + > *:nth-child(3) { + grid-column: 2/3; + grid-row: 1; + justify-self: end; + } + + ${media.sm} { + gap: ${sizes(4)}; + grid-template-columns: auto 1fr auto; + + > *:nth-child(2) { + grid-column: 2/3; + } + + > *:nth-child(3) { + grid-column: 3/4; + } + } +` + +export const FlexBox = styled.div<{ dir?: 'column' | 'row' }>` + display: flex; + flex-direction: ${(props) => props.dir ?? 'row'}; + gap: ${sizes(2)}; +` +export const StyledSvgActionTrash = styled(SvgActionTrash)` + path { + fill: ${cVar('colorTextError')}; + } +` + +export const EmojiPlaceholder = styled.div` + width: 40px; + height: 40px; + border-radius: 50%; + background: gray; +` diff --git a/packages/atlas/src/components/_inputs/BenefitInput/BenefitInput.tsx b/packages/atlas/src/components/_inputs/BenefitInput/BenefitInput.tsx new file mode 100644 index 0000000000..0ba06df159 --- /dev/null +++ b/packages/atlas/src/components/_inputs/BenefitInput/BenefitInput.tsx @@ -0,0 +1,53 @@ +import { ChangeEvent } from 'react' + +import { SvgActionChevronB, SvgActionChevronT } from '@/assets/icons' +import { Button } from '@/components/_buttons/Button' +import { + Container, + EmojiPlaceholder, + FlexBox, + StyledSvgActionTrash, +} from '@/components/_inputs/BenefitInput/BenefitInput.styles' +import { Input } from '@/components/_inputs/Input' +import { TextArea } from '@/components/_inputs/TextArea' +import { useMediaMatch } from '@/hooks/useMediaMatch' + +export type BenefitInputProps = { + position: 'last' | 'first' | 'middle' + onMoveUp: () => void + onMoveDown: () => void + onRemove: () => void + title?: string + description?: string + onTitleChange?: (e: ChangeEvent) => void + onDescriptionChange?: (e: ChangeEvent) => void +} + +export const BenefitInput = ({ + onRemove, + onMoveUp, + onMoveDown, + title, + description, + onDescriptionChange, + onTitleChange, + position, +}: BenefitInputProps) => { + const smMatch = useMediaMatch('sm') + return ( + + + + + + +