-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Carve out initial implementation * Include file list and preview feedback * Decrease feedback and hint size on input * Display file input feedback types * Extract global styles to index * Create full test coverage for FileInput * Update readme documentation, cleanup model * Add playwright test for fileInput * 0.5.0
- Loading branch information
Showing
16 changed files
with
563 additions
and
37 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,29 +1,44 @@ | ||
import React from "react" | ||
import { LoadingSpinner } from "../lib/components/LoadingSpinner" | ||
import { InputSection } from "./demos/Inputs" | ||
import { ButtonSection } from "./demos/Buttons" | ||
import { FileInputSection } from "./demos/FileInputs" | ||
import "./index.css" | ||
import { InputSection } from "./demos/Inputs" | ||
|
||
export const AppDev = () => { | ||
return ( | ||
<> | ||
<h1>PK Component Library</h1> | ||
<h2 id="Button"> | ||
<code>Button</code> | ||
</h2> | ||
<ButtonSection /> | ||
<h2 id="LoadingSpinner"> | ||
<code>LoadingSpinner</code> | ||
</h2> | ||
<section> | ||
<LoadingSpinner /> | ||
</section> | ||
<h2 id="Input"> | ||
<code>Input</code> | ||
</h2> | ||
<section> | ||
<InputSection /> | ||
</section> | ||
<div className="section-wrapper"> | ||
<h2 id="Button" className="section-header"> | ||
<code>Button</code> | ||
</h2> | ||
<ButtonSection /> | ||
</div> | ||
<div className="section-wrapper"> | ||
<h2 id="LoadingSpinner" className="section-header"> | ||
<code>LoadingSpinner</code> | ||
</h2> | ||
<section> | ||
<LoadingSpinner /> | ||
</section> | ||
</div> | ||
<div className="section-wrapper"> | ||
<h2 id="Input" className="section-header"> | ||
<code>Input</code> | ||
</h2> | ||
<section> | ||
<InputSection /> | ||
</section> | ||
</div> | ||
<div className="section-wrapper"> | ||
<h2 id="FileInput" className="section-header"> | ||
<code>FileInput</code> | ||
</h2> | ||
<section> | ||
<FileInputSection /> | ||
</section> | ||
</div> | ||
</> | ||
) | ||
} |
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,38 @@ | ||
import React from "react" | ||
import { FileInput } from "../../lib/components/FileInput" | ||
|
||
export function FileInputSection() { | ||
const onChange = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
for (const file of e.target.files || []) { | ||
console.log(file.name) | ||
} | ||
} | ||
|
||
return ( | ||
<> | ||
<div className="sub-section"> | ||
<h3>With label, hint, and file list</h3> | ||
<FileInput | ||
id="file-input-list" | ||
onChange={onChange} | ||
multiple | ||
label="Upload your résumé" | ||
fileDisplay="list" | ||
accept=".jpg,.jpeg,.png,.pdf" | ||
/> | ||
</div> | ||
<div className="sub-section"> | ||
<h3>With label hint and file preview</h3> | ||
<FileInput | ||
id="file-input-preview" | ||
onChange={onChange} | ||
fileDisplay="preview" | ||
label="Upload your photos" | ||
accept="image/*" | ||
multiple | ||
required | ||
/> | ||
</div> | ||
</> | ||
) | ||
} |
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
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,122 @@ | ||
@import "../index.css"; | ||
|
||
.pk-file-input-wrapper { | ||
position: relative; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 0.5rem; | ||
} | ||
|
||
.pk-file-input-label { | ||
--lightness: 50%; | ||
--saturation: 0%; | ||
display: inline-block; | ||
padding: var(--pk-padding-lg); | ||
border: 2px solid hsl(var(--pk-hue-secondary), var(--saturation), var(--lightness)); | ||
border-radius: var(--pk-btn-border-radius); | ||
box-shadow: var(--pk-box-shadow); | ||
color: hsl(var(--pk-hue-secondary), var(--saturation), var(--lightness)); | ||
background-color: transparent; | ||
cursor: pointer; | ||
display: flex; | ||
gap: 0.5rem; | ||
align-items: center; | ||
justify-content: center; | ||
transition: var(--pk-hover-transition); | ||
text-transform: uppercase; | ||
font-weight: 700; | ||
letter-spacing: 0.05em; | ||
} | ||
|
||
.pk-file-input-label:hover { | ||
--lightness: 40%; | ||
} | ||
|
||
.pk-file-input-label:active { | ||
transform: translate3d(0px, 1px, 5px); | ||
} | ||
|
||
.pk-file-input:focus-visible + .pk-file-input-label { | ||
outline-color: hsl(var(--pk-hue-secondary), var(--saturation), var(--lightness)); | ||
outline-width: 2px; | ||
outline-offset: 2px; | ||
outline-style: solid; | ||
} | ||
|
||
.folder-upload-icon { | ||
display: inline-block; | ||
width: 1.5rem; | ||
height: 1.5rem; | ||
fill: hsl(var(--pk-hue-secondary), var(--saturation), var(--lightness)); | ||
} | ||
|
||
.pk-file-input { | ||
width: 0.0001px; | ||
height: 0.0001px; | ||
position: absolute; | ||
-webkit-appearance: none; | ||
appearance: none; | ||
opacity: 0; | ||
} | ||
|
||
.pk-file-input:focus { | ||
outline: none; | ||
} | ||
|
||
.pk-file-input-description { | ||
font-weight: bold; | ||
} | ||
|
||
.pk-file-input-accept { | ||
font-size: 0.875rem; | ||
font-weight: thin; | ||
} | ||
|
||
.pk-file-list { | ||
margin: 0; | ||
padding: 0; | ||
list-style: none; | ||
font-size: 0.875rem; | ||
font-style: italic; | ||
} | ||
|
||
.pk-file-list-item { | ||
position: relative; | ||
} | ||
|
||
.pk-file-list-remove { | ||
padding: 0 0.25rem; | ||
} | ||
|
||
.pk-file-preview-wrapper { | ||
display: flex; | ||
gap: 0.5rem; | ||
flex-wrap: wrap; | ||
} | ||
|
||
.pk-file-preview { | ||
height: 200px; | ||
position: relative; | ||
} | ||
|
||
.pk-file-preview-image { | ||
max-width: 100%; | ||
height: 100%; | ||
object-fit: cover; | ||
} | ||
|
||
.pk-file-preview-remove { | ||
position: absolute; | ||
top: 0.25rem; | ||
right: 0.25rem; | ||
padding: 0 0.25rem; | ||
} | ||
|
||
.pk-file-list-remove > svg, | ||
.pk-file-preview-remove > svg { | ||
width: 1rem; | ||
height: 1rem; | ||
vertical-align: middle; | ||
margin-top: calc(1ex - 1cap); | ||
fill: currentColor; | ||
} |
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,7 @@ | ||
import { AllHtmlAttributes } from "../../core-types" | ||
|
||
export type TFileInputProps = AllHtmlAttributes & { | ||
id: string | ||
onChange: React.ChangeEventHandler<HTMLInputElement> | ||
fileDisplay?: "list" | "preview" | ||
} |
Oops, something went wrong.