Skip to content

Commit

Permalink
VEES 0 | Add empty block
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Melior committed Jan 4, 2025
1 parent b1825dd commit a287a68
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 68 deletions.
Binary file added public/images/document.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/weight.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions src/shared/styles/custom.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@use "@/shared/ui/Modal/ui/Modal/modal.global";

path {
transition: 0.2s d ease-in-out;
}
Expand Down
46 changes: 46 additions & 0 deletions src/shared/ui/Empty/Empty.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import Image from 'next/image';

import { Flex } from '../Flex';
import { Text } from '../Text';

import styles from './empty.module.scss';

interface IEmpty {
description?: string
icon?: React.ReactNode
title?: string
}

export const Empty = ({
description,
icon = (
<Image
alt="empty"
height={512}
src="/images/document.png"
width={512}
/>
),
title = 'Ничего не найдено...',
}: IEmpty) => (
<Flex
align="center"
className={styles.wrapper}
full={true}
gap={8}
justify="center"
vertical={true}
>
<div className={styles.icon}>
{icon}
</div>
<Flex align="center" vertical={true}>
<Text align="text-center" color="text-base-400" size="text-sm">
{title}
</Text>
<Text align="text-center" color="text-base-600" size={0.7}>
{description}
</Text>
</Flex>
</Flex>
);
11 changes: 11 additions & 0 deletions src/shared/ui/Empty/empty.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.wrapper {
height: 100%;
max-height: calc(100vh - 100px);
}

.icon {
max-width: 64px;
max-height: 64px;
pointer-events: none;
user-select: none;
}
1 change: 1 addition & 0 deletions src/shared/ui/Empty/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Empty } from './Empty';
1 change: 1 addition & 0 deletions src/shared/ui/Modal/ui/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { isClient } from '@/shared/lib/next';
import { Flex } from '@/shared/ui';

import styles from './modal.module.scss';
import './modal.global.scss';

export interface IModal {
button: React.ReactElement<{ onClick?: () => void }>
Expand Down
1 change: 1 addition & 0 deletions src/shared/ui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export * from './Background';
export * from './Button';
export * from './Chip';
export * from './Divider';
export * from './Empty';
export * from './Flex';
export * from './Header';
export * from './Icon';
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/AddExerciseModal/model/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const mockAddExerciseModal: IGroupExercises[] = [
},
{
color: '#9B693B',
exercises: ['1', '2', '3', '4'],
exercises: [],
name: 'Квадрицепсы',
},
];
147 changes: 82 additions & 65 deletions src/widgets/AddExerciseModal/ui/AddExerciseModal.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
'use client';

import { clsx } from 'clsx';
import Image from 'next/image';
import { useState } from 'react';

import { AddOutlineIcon, SettingsOutlineIcon } from '@/shared/icons';
import { Button, Flex, Text, Background, Input, ModalBase, Chip } from '@/shared/ui';
import { Button, Flex, Text, Background, Input, ModalBase, Chip, Empty } from '@/shared/ui';

import styles from './addExerciseModal.module.scss';

Expand Down Expand Up @@ -55,72 +56,88 @@ export const AddExerciseModal = ({ items }: IAddExerciseModal) => {
)}
>
<Flex className={styles.wrapper} gap="medium" vertical={true}>
{selectedGroup
? (
<Flex className={styles.groupWrapper} gap={10} vertical={true}>
<Background className={clsx(styles.group, styles.visible)}>
{selectedGroup.exercises.map((item, index) => (
<Button
align="start"
className={styles.item}
full={true}
isActiveAnimation={false}
key={item}
radius="none"
variant="none"
>
<Text className={styles.index} color="text-base-600" size={0.7}>
{`${index + 1}.`}
</Text>
<Chip>
<Text customColor={selectedGroup.color}>
{selectedGroup.name}
{selectedGroup ? (
<Flex className={styles.groupWrapper} gap={10} vertical={true}>
<Background className={clsx(styles.group, styles.visible)}>
{selectedGroup.exercises.length > 0 ? (
<>
{selectedGroup.exercises.map((item, index) => (
<Button
align="start"
className={styles.item}
full={true}
isActiveAnimation={false}
key={item}
radius="none"
variant="none"
>
<Text className={styles.index} color="text-base-600" size={0.7}>
{`${index + 1}.`}
</Text>
<Chip>
<Text customColor={selectedGroup.color}>
{selectedGroup.name}
</Text>
</Chip>
<Text size="text-sm" weight="font-light">
{item}
</Text>
</Chip>
<Text size="text-sm" weight="font-light">
{item}
</Text>
</Button>
))}
<Text
align="text-center"
className={styles.end}
color="text-base-700"
size="text-sm"
>
Это конец списка
</Text>
</Background>
<Input
className={styles.visible}
rightAction={(
<Button className={styles.buttonAdd} size="large" variant="solid">
Добавить
</Button>
)}
/>
</Flex>
)
: items.map((item) => (
<Button
className={clsx(styles.button, styles.visible)}
full={true}
key={item.name}
onClick={() => setSelectedGroup(item)}
variant="none"
</Button>
))}
<Text
align="text-center"
className={styles.end}
color="text-base-700"
size="text-sm"
>
Это конец списка
</Text>
</>
) : (
<Empty
description="Добавьте первое упражнение!"
icon={(
<Image
alt="empty"
height={512}
src="/images/weight.png"
width={512}
/>
)}
title="Здесь пока нет упражнений..."
/>
)}
</Background>
<Input
className={styles.visible}
placeholder="Название упражнения"
rightAction={(
<Button className={styles.buttonAdd} size="large" variant="solid">
Добавить
</Button>
)}
/>
</Flex>
) : items.map((item) => (
<Button
className={clsx(styles.button, styles.visible)}
full={true}
key={item.name}
onClick={() => setSelectedGroup(item)}
variant="none"
>
<span className={styles.light} style={{ backgroundColor: item.color }} />
<Text className={styles.name} customColor={item.color}>
{item.name}
</Text>
<Text
color="text-base-700"
size="text-sm"
>
<span className={styles.light} style={{ backgroundColor: item.color }} />
<Text className={styles.name} customColor={item.color}>
{item.name}
</Text>
<Text
color="text-base-700"
size="text-sm"
>
{getCountExerciseWord(item.exercises.length)}
</Text>
</Button>
))}
{getCountExerciseWord(item.exercises.length)}
</Text>
</Button>
))}
</Flex>
</ModalBase>
);
Expand Down

0 comments on commit a287a68

Please sign in to comment.