mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-14 18:01:06 +00:00
feat(file-uploader): add size
prop to FileUploaderButton
(#1786)
This commit is contained in:
parent
709322c281
commit
51c281de4a
8 changed files with 70 additions and 5 deletions
|
@ -1261,6 +1261,7 @@ None.
|
||||||
| labelTitle | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the label title.<br />Alternatively, use the named slot "labelTitle" (e.g., `<span slot="labelTitle">...</span>`) |
|
| labelTitle | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the label title.<br />Alternatively, use the named slot "labelTitle" (e.g., `<span slot="labelTitle">...</span>`) |
|
||||||
| labelDescription | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the label description.<br />Alternatively, use the named slot "labelDescription" (e.g., `<span slot="labelDescription">...</span>`) |
|
| labelDescription | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the label description.<br />Alternatively, use the named slot "labelDescription" (e.g., `<span slot="labelDescription">...</span>`) |
|
||||||
| kind | No | <code>let</code> | No | <code>import("../Button/Button.svelte").ButtonProps["kind"]</code> | <code>"primary"</code> | Specify the kind of file uploader button |
|
| kind | No | <code>let</code> | No | <code>import("../Button/Button.svelte").ButtonProps["kind"]</code> | <code>"primary"</code> | Specify the kind of file uploader button |
|
||||||
|
| size | No | <code>let</code> | No | <code>import("../Button/Button.svelte").ButtonProps["size"]</code> | <code>"small"</code> | Specify the size of the file uploader button |
|
||||||
| buttonLabel | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the button label |
|
| buttonLabel | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the button label |
|
||||||
| iconDescription | No | <code>let</code> | No | <code>string</code> | <code>"Provide icon description"</code> | Specify the ARIA label used for the status icons |
|
| iconDescription | No | <code>let</code> | No | <code>string</code> | <code>"Provide icon description"</code> | Specify the ARIA label used for the status icons |
|
||||||
| name | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify a name attribute for the file button uploader input |
|
| name | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify a name attribute for the file button uploader input |
|
||||||
|
@ -1299,6 +1300,7 @@ None.
|
||||||
| disabled | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable the input |
|
| disabled | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable the input |
|
||||||
| disableLabelChanges | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable label changes |
|
| disableLabelChanges | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable label changes |
|
||||||
| kind | No | <code>let</code> | No | <code>import("../Button/Button.svelte").ButtonProps["kind"]</code> | <code>"primary"</code> | Specify the kind of file uploader button |
|
| kind | No | <code>let</code> | No | <code>import("../Button/Button.svelte").ButtonProps["kind"]</code> | <code>"primary"</code> | Specify the kind of file uploader button |
|
||||||
|
| size | No | <code>let</code> | No | <code>import("../Button/Button.svelte").ButtonProps["size"]</code> | <code>"small"</code> | Specify the size of the file uploader button |
|
||||||
| role | No | <code>let</code> | No | <code>string</code> | <code>"button"</code> | Specify the label role |
|
| role | No | <code>let</code> | No | <code>string</code> | <code>"button"</code> | Specify the label role |
|
||||||
| tabindex | No | <code>let</code> | No | <code>string</code> | <code>"0"</code> | Specify `tabindex` attribute |
|
| tabindex | No | <code>let</code> | No | <code>string</code> | <code>"0"</code> | Specify `tabindex` attribute |
|
||||||
| id | No | <code>let</code> | No | <code>string</code> | <code>"ccs-" + Math.random().toString(36)</code> | Set an id for the input element |
|
| id | No | <code>let</code> | No | <code>string</code> | <code>"ccs-" + Math.random().toString(36)</code> | Set an id for the input element |
|
||||||
|
|
|
@ -3830,6 +3830,18 @@
|
||||||
"constant": false,
|
"constant": false,
|
||||||
"reactive": false
|
"reactive": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "size",
|
||||||
|
"kind": "let",
|
||||||
|
"description": "Specify the size of the file uploader button",
|
||||||
|
"type": "import(\"../Button/Button.svelte\").ButtonProps[\"size\"]",
|
||||||
|
"value": "\"small\"",
|
||||||
|
"isFunction": false,
|
||||||
|
"isFunctionDeclaration": false,
|
||||||
|
"isRequired": false,
|
||||||
|
"constant": false,
|
||||||
|
"reactive": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "buttonLabel",
|
"name": "buttonLabel",
|
||||||
"kind": "let",
|
"kind": "let",
|
||||||
|
@ -3983,6 +3995,18 @@
|
||||||
"constant": false,
|
"constant": false,
|
||||||
"reactive": false
|
"reactive": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "size",
|
||||||
|
"kind": "let",
|
||||||
|
"description": "Specify the size of the file uploader button",
|
||||||
|
"type": "import(\"../Button/Button.svelte\").ButtonProps[\"size\"]",
|
||||||
|
"value": "\"small\"",
|
||||||
|
"isFunction": false,
|
||||||
|
"isFunctionDeclaration": false,
|
||||||
|
"isRequired": false,
|
||||||
|
"constant": false,
|
||||||
|
"reactive": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "labelText",
|
"name": "labelText",
|
||||||
"kind": "let",
|
"kind": "let",
|
||||||
|
|
|
@ -13,13 +13,22 @@ By default, the file uploader only accepts one file.
|
||||||
|
|
||||||
Set `multiple` to `true` for multiple files to be accepted.
|
Set `multiple` to `true` for multiple files to be accepted.
|
||||||
|
|
||||||
<FileUploaderButton labelText="Add files" />
|
<FileUploaderButton labelText="Add file" />
|
||||||
|
|
||||||
## Custom button kind
|
## Multiple files
|
||||||
|
|
||||||
By default, the `primary` button kind is used.
|
<FileUploaderButton multiple labelText="Add files" />
|
||||||
|
|
||||||
<FileUploaderButton kind="secondary" labelText="Add files" />
|
## Custom button kind, size
|
||||||
|
|
||||||
|
By default, the `primary` small button kind is used.
|
||||||
|
|
||||||
|
Use the `kind` and `size` props to customize the button.
|
||||||
|
|
||||||
|
<FileUploaderButton kind="secondary" size="field" />
|
||||||
|
<FileUploaderButton kind="tertiary" size="default" />
|
||||||
|
<FileUploaderButton kind="danger" size="lg" />
|
||||||
|
<FileUploaderButton kind="danger-tertiary" size="xl" />
|
||||||
|
|
||||||
## File uploader
|
## File uploader
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,12 @@
|
||||||
*/
|
*/
|
||||||
export let kind = "primary";
|
export let kind = "primary";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify the size of the file uploader button
|
||||||
|
* @type {import("../Button/Button.svelte").ButtonProps["size"]}
|
||||||
|
*/
|
||||||
|
export let size = "small";
|
||||||
|
|
||||||
/** Specify the button label */
|
/** Specify the button label */
|
||||||
export let buttonLabel = "";
|
export let buttonLabel = "";
|
||||||
|
|
||||||
|
@ -137,6 +143,7 @@
|
||||||
name="{name}"
|
name="{name}"
|
||||||
multiple="{multiple}"
|
multiple="{multiple}"
|
||||||
kind="{kind}"
|
kind="{kind}"
|
||||||
|
size="{size}"
|
||||||
on:change
|
on:change
|
||||||
on:change="{(e) => {
|
on:change="{(e) => {
|
||||||
files = e.detail;
|
files = e.detail;
|
||||||
|
|
|
@ -30,6 +30,12 @@
|
||||||
*/
|
*/
|
||||||
export let kind = "primary";
|
export let kind = "primary";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify the size of the file uploader button
|
||||||
|
* @type {import("../Button/Button.svelte").ButtonProps["size"]}
|
||||||
|
*/
|
||||||
|
export let size = "small";
|
||||||
|
|
||||||
/** Specify the label text */
|
/** Specify the label text */
|
||||||
export let labelText = "Add file";
|
export let labelText = "Add file";
|
||||||
|
|
||||||
|
@ -67,7 +73,6 @@
|
||||||
for="{id}"
|
for="{id}"
|
||||||
tabindex="{disabled ? '-1' : tabindex}"
|
tabindex="{disabled ? '-1' : tabindex}"
|
||||||
class:bx--btn="{true}"
|
class:bx--btn="{true}"
|
||||||
class:bx--btn--sm="{true}"
|
|
||||||
class:bx--btn--disabled="{disabled}"
|
class:bx--btn--disabled="{disabled}"
|
||||||
class:bx--btn--primary="{kind === 'primary'}"
|
class:bx--btn--primary="{kind === 'primary'}"
|
||||||
class:bx--btn--secondary="{kind === 'secondary'}"
|
class:bx--btn--secondary="{kind === 'secondary'}"
|
||||||
|
@ -76,6 +81,10 @@
|
||||||
class:bx--btn--danger="{kind === 'danger'}"
|
class:bx--btn--danger="{kind === 'danger'}"
|
||||||
class:bx--btn--danger-tertiary="{kind === 'danger-tertiary'}"
|
class:bx--btn--danger-tertiary="{kind === 'danger-tertiary'}"
|
||||||
class:bx--btn--danger-ghost="{kind === 'danger-ghost'}"
|
class:bx--btn--danger-ghost="{kind === 'danger-ghost'}"
|
||||||
|
class:bx--btn--sm="{size === 'small'}"
|
||||||
|
class:bx--btn--field="{size === 'field'}"
|
||||||
|
class:bx--btn--lg="{size === 'lg'}"
|
||||||
|
class:bx--btn--xl="{size === 'xl'}"
|
||||||
on:keydown
|
on:keydown
|
||||||
on:keydown="{({ key }) => {
|
on:keydown="{({ key }) => {
|
||||||
if (key === ' ' || key === 'Enter') {
|
if (key === ' ' || key === 'Enter') {
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
<FileUploaderButton
|
<FileUploaderButton
|
||||||
kind="tertiary"
|
kind="tertiary"
|
||||||
|
size="xl"
|
||||||
labelText="Add files"
|
labelText="Add files"
|
||||||
on:change="{(e) => {
|
on:change="{(e) => {
|
||||||
console.log(e.detail); // File[]
|
console.log(e.detail); // File[]
|
||||||
|
@ -29,6 +30,7 @@
|
||||||
|
|
||||||
<FileUploader
|
<FileUploader
|
||||||
kind="danger-ghost"
|
kind="danger-ghost"
|
||||||
|
size="lg"
|
||||||
bind:this="{fileUploader}"
|
bind:this="{fileUploader}"
|
||||||
multiple
|
multiple
|
||||||
labelTitle="Upload files"
|
labelTitle="Upload files"
|
||||||
|
|
6
types/FileUploader/FileUploader.svelte.d.ts
vendored
6
types/FileUploader/FileUploader.svelte.d.ts
vendored
|
@ -54,6 +54,12 @@ export interface FileUploaderProps extends RestProps {
|
||||||
*/
|
*/
|
||||||
kind?: import("../Button/Button.svelte").ButtonProps["kind"];
|
kind?: import("../Button/Button.svelte").ButtonProps["kind"];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify the size of the file uploader button
|
||||||
|
* @default "small"
|
||||||
|
*/
|
||||||
|
size?: import("../Button/Button.svelte").ButtonProps["size"];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify the button label
|
* Specify the button label
|
||||||
* @default ""
|
* @default ""
|
||||||
|
|
|
@ -40,6 +40,12 @@ export interface FileUploaderButtonProps extends RestProps {
|
||||||
*/
|
*/
|
||||||
kind?: import("../Button/Button.svelte").ButtonProps["kind"];
|
kind?: import("../Button/Button.svelte").ButtonProps["kind"];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify the size of the file uploader button
|
||||||
|
* @default "small"
|
||||||
|
*/
|
||||||
|
size?: import("../Button/Button.svelte").ButtonProps["size"];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify the label text
|
* Specify the label text
|
||||||
* @default "Add file"
|
* @default "Add file"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue