Skip to content

Commit

Permalink
Merge 4be5c52 into d9a372d
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiefolsom authored Sep 27, 2023
2 parents d9a372d + 4be5c52 commit aedfd3d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/semantic-ui/src/components/FileInputButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,20 @@
import React, { useRef } from 'react';
import { Button } from 'semantic-ui-react';

/**
* multiple?: boolean,
* onSelection: (files: Array<File>) => void
*/
type Props = {
multiple?: boolean,
onSelection: (files: Array<File>) => void
};

/**
* This component is used to allow a user to upload one or more files
* from their file system. This component also accepts
* all of the props of the Semantic UI <code>Button</code> component.
*/
const FileInputButton = ({ onSelection, multiple, ...buttonProps }: Props) => {
const fileInputRef = useRef();

Expand Down
31 changes: 31 additions & 0 deletions packages/storybook/src/semantic-ui/FileInputButton.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// @flow

import React, { useCallback } from 'react';
import { withKnobs } from '@storybook/addon-knobs';
import { Button } from 'semantic-ui-react';
import FileInputButton from '../../../semantic-ui/src/components/FileInputButton';

export default {
title: 'Components/Semantic UI/FileInputButton',
component: FileInputButton,
decorators: [withKnobs]
};
export const Default = () => {
/**
*
* @type {}
*/
const onSelection = useCallback((item) => {
// Question: how does one get the file name from the item?
// Question: once the file is selected, how to we start the upload?
});

return (
<FileInputButton
content='Select a file to upload'
icon='times'
multiple={false}
onSelection={onSelection}
/>
);
};

0 comments on commit aedfd3d

Please sign in to comment.