-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
75 additions
and
0 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
packages/dnb-eufemia/src/extensions/forms/Value/Upload/stories/Upload.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { Form, Value } from '../../..' | ||
import { Card } from '../../../../../components' | ||
|
||
export default { | ||
title: 'Eufemia/Extensions/Forms/Value/Upload', | ||
} | ||
|
||
function createMockFile(name: string, size: number, type: string) { | ||
const file = new File([], name, { type }) | ||
Object.defineProperty(file, 'size', { | ||
get() { | ||
return size | ||
}, | ||
}) | ||
return file | ||
} | ||
|
||
export function Upload() { | ||
return ( | ||
<Form.Handler | ||
data={{ | ||
foo: 'John', | ||
bar: 'Doe', | ||
baz: [ | ||
{ | ||
file: createMockFile('fileName-1.png', 1000000, 'image/png'), | ||
exists: false, | ||
id: '1', | ||
}, | ||
{ | ||
file: createMockFile('fileName-2.png', 2000000, 'image/png'), | ||
exists: false, | ||
id: '2', | ||
}, | ||
{ | ||
file: createMockFile('fileName-3.png', 3000000, 'image/png'), | ||
exists: false, | ||
id: '3', | ||
}, | ||
], | ||
}} | ||
> | ||
<Card> | ||
<Value.SummaryList | ||
layout="grid" | ||
transformLabel={(label: string) => label.toUpperCase()} | ||
> | ||
<Value.String label="foo" path="/foo" /> | ||
<Value.String label="bar" path="/bar" /> | ||
<Value.Upload label="baz" path="/baz" /> | ||
</Value.SummaryList> | ||
</Card> | ||
<Card> | ||
<Value.SummaryList | ||
layout="horizontal" | ||
transformLabel={(label: string) => label.toUpperCase()} | ||
> | ||
<Value.String label="foo" path="/foo" /> | ||
<Value.String label="bar" path="/bar" /> | ||
<Value.Upload label="baz" path="/baz" /> | ||
</Value.SummaryList> | ||
</Card> | ||
<Card> | ||
<Value.SummaryList | ||
layout="vertical" | ||
transformLabel={(label: string) => label.toUpperCase()} | ||
> | ||
<Value.String label="foo" path="/foo" /> | ||
<Value.String label="bar" path="/bar" /> | ||
<Value.Upload label="baz" path="/baz" /> | ||
</Value.SummaryList> | ||
</Card> | ||
</Form.Handler> | ||
) | ||
} |