Skip to content

Commit

Permalink
Merge branch 'main' into feat/rating-group
Browse files Browse the repository at this point in the history
  • Loading branch information
HBS999 authored Nov 4, 2024
2 parents 3d9ce3b + 9abd5d0 commit 94988e7
Show file tree
Hide file tree
Showing 41 changed files with 4,484 additions and 365 deletions.
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
auto-install-peers=true
strict-peer-dependencies=false
link-workspace-packages=true
prefer-workspace-packages=true
15 changes: 8 additions & 7 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,37 +34,38 @@
"dependencies": {
"@docsearch/css": "3.5.2",
"@docsearch/js": "3.5.2",
"@kobalte/core": "0.13.7",
"@kobalte/core": "workspace:*",
"@solidjs/meta": "0.29.3",
"@solidjs/router": "0.12.4",
"@solidjs/start": "0.6.1",
"@tanstack/solid-virtual": "3.0.0-beta.6",
"clsx": "2.0.0",
"minisearch": "7.1.0",
"solid-js": "1.8.15",
"@solidjs/start": "0.6.1",
"vinxi": "0.3.9",
"undici": "5.23.0"
"undici": "5.23.0",
"vinxi": "0.3.9"
},
"devDependencies": {
"@kobalte/tailwindcss": "0.9.0",
"@mdx-js/mdx": "3.0.0",
"@mdx-js/rollup": "3.0.0",
"@tailwindcss/typography": "0.5.9",
"@vinxi/plugin-mdx": "3.7.1",
"acorn": "8.10.0",
"autoprefixer": "10.4.15",
"github-slugger": "2.0.0",
"postcss": "8.4.28",
"rehype-pretty-code": "0.12.3",
"remark-shiki-twoslash": "3.1.3",
"rehype-raw": "7.0.0",
"rehype-slug": "6.0.0",
"remark-gfm": "4.0.0",
"remark-shiki-twoslash": "3.1.3",
"shiki": "0.14.7",
"solid-mdx": "0.0.7",
"tailwindcss": "3.3.3",
"typescript": "4.9.5",
"unist-util-visit": "5.0.0",
"vite": "5.1.4",
"@vinxi/plugin-mdx": "3.7.1"
"vite": "5.1.4"
},
"engines": {
"node": ">=18"
Expand Down
38 changes: 38 additions & 0 deletions apps/docs/src/components/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,41 @@ export function ArrowIcon(props: ComponentProps<"svg">) {
</svg>
);
}

export function MagnifyingGlassIcon(props: ComponentProps<"svg">) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 15 15"
fill="currentColor"
{...props}
>
<title>Magnifying Glass</title>
<path
d="M10 6.5C10 8.433 8.433 10 6.5 10C4.567 10 3 8.433 3 6.5C3 4.567 4.567 3 6.5 3C8.433 3 10 4.567 10 6.5ZM9.30884 10.0159C8.53901 10.6318 7.56251 11 6.5 11C4.01472 11 2 8.98528 2 6.5C2 4.01472 4.01472 2 6.5 2C8.98528 2 11 4.01472 11 6.5C11 7.56251 10.6318 8.53901 10.0159 9.30884L12.8536 12.1464C13.0488 12.3417 13.0488 12.6583 12.8536 12.8536C12.6583 13.0488 12.3417 13.0488 12.1464 12.8536L9.30884 10.0159Z"
fill="currentColor"
fill-rule="evenodd"
clip-rule="evenodd"
/>
</svg>
);
}

export function ReloadIcon(props: ComponentProps<"svg">) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 15 15"
fill="currentColor"
{...props}
>
<title>Reload</title>
<path
d="M1.84998 7.49998C1.84998 4.66458 4.05979 1.84998 7.49998 1.84998C10.2783 1.84998 11.6515 3.9064 12.2367 5H10.5C10.2239 5 10 5.22386 10 5.5C10 5.77614 10.2239 6 10.5 6H13.5C13.7761 6 14 5.77614 14 5.5V2.5C14 2.22386 13.7761 2 13.5 2C13.2239 2 13 2.22386 13 2.5V4.31318C12.2955 3.07126 10.6659 0.849976 7.49998 0.849976C3.43716 0.849976 0.849976 4.18537 0.849976 7.49998C0.849976 10.8146 3.43716 14.15 7.49998 14.15C9.44382 14.15 11.0622 13.3808 12.2145 12.2084C12.8315 11.5806 13.3133 10.839 13.6418 10.0407C13.7469 9.78536 13.6251 9.49315 13.3698 9.38806C13.1144 9.28296 12.8222 9.40478 12.7171 9.66014C12.4363 10.3425 12.0251 10.9745 11.5013 11.5074C10.5295 12.4963 9.16504 13.15 7.49998 13.15C4.05979 13.15 1.84998 10.3354 1.84998 7.49998Z"
fill="currentColor"
fill-rule="evenodd"
clip-rule="evenodd"
/>
</svg>
);
}
114 changes: 114 additions & 0 deletions apps/docs/src/examples/file-upload.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
.fileUpload {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
min-height: 300px;
row-gap: 5px;
}

.fileUpload__label {
color: white;
font-size: 14px;
font-weight: 500;
user-select: none;
}

.fileUpload__dropzone {
padding: 20px;
display: flex;
flex-direction: column;
row-gap: 10px;
align-items: center;
justify-content: center;
border: 1px dashed rgb(42, 42, 40);
width: 100%;
min-height: 200px;
color: #ccc;
border-radius: 6px;
}

.fileUpload__trigger {
background-color: hsl(201 96% 32%);
color: white;
padding: 5px 10px;
border-radius: 4px;
}

.fileUpload__itemGroup {
display: flex;
flex-direction: column;
gap: 3px;
width: 100%;
}

.fileUpload__item {
width: 100%;
display: grid;
padding: 16px;
column-gap: 10px;
border-radius: 6px;
grid-template-columns: auto 1fr auto;
grid-template-areas:
"preview name delete"
"preview size delete";
column-gap: 5px;
border: 1px solid rgb(42, 42, 40);
padding: 10px;
}

.fileUpload__itemPreview {
grid-area: preview;
}

.fileUpload__itemPreviewImage {
width: 50px;
object-fit: scale-down;
height: auto;
aspect-ratio: 1;
}

.fileUpload__itemName {
grid-area: name;
font-size: 14px;
color: #fff;
}

.fileUpload__itemSize {
grid-area: size;
font-size: 14px;
color: rgb(181, 179, 173);
}

.fileUpload__itemDeleteTrigger {
grid-area: delete;
cursor: pointer;
background-color: #a23434;
color: white;
padding: 2px 8px;
border-radius: 4px;
height: max-content;
align-self: center;
}

.formContainer {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
row-gap: 5px;
}

.formContainer > .fileUpload__dropzone {
min-height: 200px;
}

.submit-btn {
background-color: hsl(201 96% 32%);
color: white;
padding: 5px 10px;
border-radius: 4px;
align-self: flex-end;
}
131 changes: 131 additions & 0 deletions apps/docs/src/examples/file-upload.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
import { FileUpload } from "@kobalte/core/file-upload";
import { For } from "solid-js";

import style from "./file-upload.module.css";

export function BasicExample() {
return (
<FileUpload
class={style.fileUpload}
multiple
maxFiles={5}
onFileAccept={(data) => console.log("data", data)}
onFileReject={(data) => console.log("data", data)}
onFileChange={(data) => console.log("data", data)}
>
<FileUpload.Label class={style.fileUpload__label}>
File Upload
</FileUpload.Label>
<FileUpload.DropZone class={style.fileUpload__dropzone}>
Drop your files here...
<FileUpload.Trigger class={style.fileUpload__trigger}>
Choose files!
</FileUpload.Trigger>
</FileUpload.DropZone>
<FileUpload.HiddenInput />
<FileUpload.ItemGroup class={style.fileUpload__itemGroup}>
<FileUpload.Context>
{(context) => {
return (
<For each={context.acceptedFiles}>
{(file) => (
<FileUpload.Item file={file} class={style.fileUpload__item}>
<FileUpload.ItemPreview
type="image/*"
class={style.fileUpload__itemPreview}
>
<FileUpload.ItemPreviewImage
class={style.fileUpload__itemPreviewImage}
/>
</FileUpload.ItemPreview>
<FileUpload.ItemName class={style.fileUpload__itemName} />
<FileUpload.ItemSize class={style.fileUpload__itemSize} />
<FileUpload.ItemDeleteTrigger
class={style.fileUpload__itemDeleteTrigger}
>
Delete
</FileUpload.ItemDeleteTrigger>
</FileUpload.Item>
)}
</For>
);
}}
</FileUpload.Context>
</FileUpload.ItemGroup>
</FileUpload>
);
}

export function HTMLFormExample() {
let formRef: HTMLFormElement | undefined;

const onSubmit = (event: SubmitEvent) => {
event.preventDefault();
event.stopPropagation();

const formData = new FormData(formRef);
const uploadedFiles = formData.getAll("uploaded-files");

const fileNames = uploadedFiles
.filter((file): file is File => file instanceof File)
.map((file) => file.name);

alert(JSON.stringify(fileNames, null, 2));
};

return (
<form class={style.formContainer} ref={formRef} onSubmit={onSubmit}>
<FileUpload
class={style.fileUpload}
multiple
maxFiles={5}
onFileAccept={(data) => console.log("data", data)}
onFileReject={(data) => console.log("data", data)}
onFileChange={(data) => console.log("data", data)}
>
<FileUpload.Label class={style.fileUpload__label}>
File Upload
</FileUpload.Label>
<FileUpload.DropZone class={style.fileUpload__dropzone}>
Drop your files here...
<FileUpload.Trigger class={style.fileUpload__trigger}>
Choose files!
</FileUpload.Trigger>
</FileUpload.DropZone>
<FileUpload.HiddenInput name="uploaded-files" />
<FileUpload.ItemGroup class={style.fileUpload__itemGroup}>
<FileUpload.Context>
{(context) => {
return (
<For each={context.acceptedFiles}>
{(file) => (
<FileUpload.Item file={file} class={style.fileUpload__item}>
<FileUpload.ItemPreview
type="image/*"
class={style.fileUpload__itemPreview}
>
<FileUpload.ItemPreviewImage
class={style.fileUpload__itemPreviewImage}
/>
</FileUpload.ItemPreview>
<FileUpload.ItemName class={style.fileUpload__itemName} />
<FileUpload.ItemSize class={style.fileUpload__itemSize} />
<FileUpload.ItemDeleteTrigger
class={style.fileUpload__itemDeleteTrigger}
>
Delete
</FileUpload.ItemDeleteTrigger>
</FileUpload.Item>
)}
</For>
);
}}
</FileUpload.Context>
</FileUpload.ItemGroup>
</FileUpload>
<button type="submit" class={style["submit-btn"]}>
Submit Files
</button>
</form>
);
}
Loading

0 comments on commit 94988e7

Please sign in to comment.