-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Asset Upload component (#1509)
* Add asset-upload component
- Loading branch information
Saad M
authored
Jul 9, 2019
1 parent
1b6dfc2
commit 49dd334
Showing
13 changed files
with
203 additions
and
2 deletions.
There are no files selected for viewing
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
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,52 @@ | ||
--- | ||
title: Asset Upload | ||
id: asset-upload | ||
keywords: asset upload, file upload, asset, file, upload | ||
sidebar: left-navigation-sidebar | ||
toc: false | ||
permalink: components/asset-upload.html | ||
folder: components | ||
summary: | ||
--- | ||
|
||
Asset Upload provides a stylized component for file upload button. | ||
{: .docs-intro} | ||
|
||
## Default Asset Upload | ||
|
||
{% capture default %} | ||
<div class="fd-asset-upload"> | ||
<input type="file" id="asset-upload" class="fd-asset-upload__input"/> | ||
<label for="asset-upload" class="fd-asset-upload__label"> | ||
<span class="fd-asset-upload__text">Upload Link</span> | ||
<span class="fd-asset-upload__message">Maximum file size is 100MB</span> | ||
</label> | ||
</div> | ||
{% endcapture %} | ||
{% include display-component.html component=default %} | ||
|
||
## Asset Upload with no message | ||
Optional message can be excluded by removing the span tag containing `fd-asset-upload__message` class. | ||
|
||
{% capture default %} | ||
<div class="fd-asset-upload"> | ||
<input type="file" id="asset-upload" class="fd-asset-upload__input"/> | ||
<label for="asset-upload" class="fd-asset-upload__label"> | ||
<span class="fd-asset-upload__text">Upload Link</span> | ||
</label> | ||
</div> | ||
{% endcapture %} | ||
{% include display-component.html component=default %} | ||
|
||
## Asset Upload with no icon | ||
Add the modifier class `fd-asset-upload--no-icon` to supress the upload icon. | ||
|
||
{% capture default %} | ||
<div class="fd-asset-upload fd-asset-upload--no-icon"> | ||
<input type="file" id="asset-upload" class="fd-asset-upload__input"/> | ||
<label for="asset-upload" class="fd-asset-upload__label"> | ||
<span class="fd-asset-upload__text">Upload Link</span> | ||
</label> | ||
</div> | ||
{% endcapture %} | ||
{% include display-component.html component=default %} |
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
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,67 @@ | ||
@import "./../settings"; | ||
@import "./../mixins"; | ||
@import "./../functions"; | ||
@import "./../icons/mixins"; | ||
/*! | ||
.fd-asset-upload+(--no-icon) | ||
.fd-asset-upload__label | ||
.fd-asset-upload__text | ||
.fd-asset-upload__message | ||
*/ | ||
$block: #{$fd-namespace}-asset-upload; | ||
.#{$block} { | ||
|
||
@include fd-reset(); | ||
@include fd-type("0"); | ||
$fd-asset-upload-padding: fd-space(3); | ||
$fd-asset-upload-border-radius: fd-space(1); | ||
$fd-asset-upload-border-color: var(--fd-color-neutral-4); | ||
$fd-asset-upload-background-color: var(--fd-color-neutral-1); | ||
$fd-asset-upload-text-color: var(--fd-color-action-1); | ||
$fd-asset-upload-border-color--hover: var(--fd-color-action-1); | ||
$fd-asset-upload-border-color--focus: var(--fd-color-action-focus); | ||
|
||
&__input { | ||
height: 0; | ||
width: 0; | ||
overflow: hidden; | ||
|
||
&:focus + .#{$block}__label { | ||
border: 1px solid $fd-asset-upload-border-color--focus; | ||
box-shadow: 0 0 0 1px $fd-asset-upload-border-color--focus; | ||
} | ||
} | ||
|
||
&__input + .#{$block}__label { | ||
background-color: $fd-asset-upload-background-color; | ||
border: 1px dashed $fd-asset-upload-border-color; | ||
text-align: center; | ||
padding: $fd-asset-upload-padding; | ||
border-radius: $fd-asset-upload-border-radius; | ||
cursor: pointer; | ||
display: block; | ||
|
||
&:hover { | ||
border-style: solid; | ||
border-color: $fd-asset-upload-border-color--hover; | ||
} | ||
} | ||
|
||
&__text { | ||
display: block; | ||
color: $fd-asset-upload-text-color; | ||
@include fd-icon("upload-to-cloud", "m"); | ||
margin-bottom: fd-space(.5); | ||
|
||
&::before { | ||
display: block; | ||
margin-bottom: fd-space(1); | ||
} | ||
} | ||
|
||
&--no-icon { | ||
.#{$block}__text::before { | ||
display: none; | ||
} | ||
} | ||
} |
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,17 @@ | ||
|
||
<!-- | ||
asset-upload: | ||
properties={}, | ||
modifier={ block: [] } | ||
--> | ||
{% macro asset_upload(properties={}, modifier={}, state={}, aria={}, classes=[]) -%} | ||
<div class="fd-asset-upload{{ modifier.block | modifier('asset-upload') }}{{classes|classes}}"> | ||
<input type="file" id="asset-upload" class="fd-asset-upload__input"/> | ||
<label for="asset-upload" class="fd-asset-upload__label"> | ||
<span class="fd-asset-upload__text">{{properties.text}}</span> | ||
{%- if properties.message %} | ||
<span class="fd-asset-upload__message">{{properties.message}}</span> | ||
{%- endif %} | ||
</label> | ||
</div> | ||
{%- endmacro %} |
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,16 @@ | ||
{ | ||
"id": "file-upload", | ||
"name": "File Upload", | ||
"css_vars": true, | ||
"rtl": true, | ||
"version": "1.0.0", | ||
"properties": { | ||
"text": "Upload Link", | ||
"message": "" | ||
}, | ||
"modifier": { | ||
"block": [] | ||
}, | ||
"state": {}, | ||
"aria": {} | ||
} |
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,44 @@ | ||
{% extends "layout.njk" %} | ||
{% from "./../format.njk" import format %} | ||
{# {% from "../button/component.njk" import button %} #} | ||
{% from "./component.njk" import asset_upload %} | ||
{% from "../icon/component.njk" import icon %} | ||
|
||
{% block content %} | ||
|
||
|
||
<h2>default</h2> | ||
<!-- output the component example and the code snippet --> | ||
{% set example %} | ||
{{ asset_upload( | ||
properties={ | ||
text: "Upload Link", | ||
message: "Maximum file size is 100MB" | ||
} | ||
) | ||
}} | ||
{{ asset_upload( | ||
properties={ | ||
text: "Upload Link" | ||
} | ||
) | ||
}} | ||
{{ asset_upload( | ||
properties={ | ||
text: "Upload Link", | ||
message: "Maximum file size is 100MB" | ||
}, | ||
modifier={ block:['no-icon']}) | ||
}} | ||
{{ asset_upload( | ||
properties={ | ||
text: "Upload Link" | ||
}, | ||
modifier={ block:['no-icon']}) | ||
}} | ||
|
||
|
||
{% endset %} | ||
{{ format(example) }} | ||
|
||
{% endblock %} |
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
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{% import "./../utils.njk" as utils %} | ||
{% from "../icon/component.njk" import icon %} | ||
<!-- | ||
menu: | ||
properties={}, | ||
|
Binary file modified
BIN
+180 Bytes
(100%)
...ssion_fundamental_asset-upload_0_example-containerfd-asset-upload_0_desktop.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 modified
BIN
+2.91 KB
(150%)
...n_fundamental_asset-upload_1_example-containerfd-asset-upload__n1_0_desktop.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 modified
BIN
-2.74 KB
(75%)
...n_fundamental_asset-upload_2_example-containerfd-asset-upload__n2_0_desktop.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 modified
BIN
+2.88 KB
(150%)
...n_fundamental_asset-upload_3_example-containerfd-asset-upload__n3_0_desktop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.