Skip to content

Commit

Permalink
feat (redmine 1246935): add files cards and fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
vapersmile committed Oct 10, 2023
1 parent 6a429b6 commit 25836b3
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
import type { FileWithPath } from '@mantine/dropzone';
import type { Meta, StoryObj } from '@storybook/react';

import { useStorybookArgsConnect } from '@smile/react-front-kit-shared/src/storybook-utils';

import { Dropzone as Cmp } from './Dropzone';

const meta = {
component: Cmp,
decorators: [
function Component(Story, ctx) {
const args = useStorybookArgsConnect(ctx.args, {
onDrop: 'files',
});
return <Story args={{ ...args }} />;
},
],
tags: ['autodocs'],
title: '3-custom/Components/Dropzone',
} satisfies Meta<typeof Cmp>;
Expand All @@ -26,12 +16,37 @@ export const Dropzone: IStory = {
args: {
children: undefined,
files: [
{ name: 'Test 1 demi', size: 2400000 },
{ name: 'Test 1 demi', size: 2400000 },
{ name: 'Test 1 demi', size: 2400000 },
{ name: 'Test 1 demi', size: 2400000 },
{
lastModified: 1682342930770,
name: 'CERFA.postman_collection.json',
path: 'CERFA.postman_collection.json',
size: 1579,
type: 'application/json',
},
{
lastModified: 1682342930770,
name: 'CERFA.postman_collection.json',
path: 'CERFA.postman_collection.json',
size: 1579,
type: 'application/json',
},
{
lastModified: 1682342930770,
name: 'CERFA.postman_collection.json',
path: 'CERFA.postman_collection.json',
size: 1579,
type: 'application/json',
},
{
lastModified: 1682342930770,
name: 'CERFA.postman_collection.json',
path: 'CERFA.postman_collection.json',
size: 1579,
type: 'application/json',
},
],
onDrop: (files: FileWithPath[]): void => {
// eslint-disable-next-line no-console
console.log(files);
},
},
Expand Down
19 changes: 11 additions & 8 deletions packages/react-front-kit/src/Components/Dropzone/Dropzone.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
'use client';

import type {
FileWithPath,
DropzoneProps as IMantineDropzoneProps,
} from '@mantine/dropzone';
import type { DropzoneProps as IMantineDropzoneProps } from '@mantine/dropzone';
import type { ReactElement } from 'react';

import { ActionIcon, Tooltip } from '@mantine/core';
Expand All @@ -14,7 +11,13 @@ import { Eye, Plus } from '@phosphor-icons/react';
export interface IDropzoneProps
extends Omit<IMantineDropzoneProps, 'children'> {
children?: ReactElement;
files?: FileWithPath[];
files?: {
lastModified: number;
name: string;
path: string;
size: number;
type: string;
}[];
}

const useStyles = createStyles((theme) => ({
Expand All @@ -35,7 +38,7 @@ const useStyles = createStyles((theme) => ({
height: '70px',
margin: '10px',
padding: '10px',
width: '75px',
width: '170px',
},
cardFileText: {
'&:first-of-type': {
Expand Down Expand Up @@ -111,8 +114,8 @@ export function Dropzone(props: IDropzoneProps): ReactElement {
>
<div className={classes.cardFile}>
<span className={classes.cardFileText}>
{file.name.length > 7
? `${file.name.slice(0, 7)}...`
{file.name.length > 15
? `${file.name.slice(0, 15)}...`
: file.name}
</span>
<span className={classes.cardFileText}>
Expand Down

0 comments on commit 25836b3

Please sign in to comment.