Design changes

This commit is contained in:
Arnaud 2024-11-04 12:34:42 +01:00
parent d06e0f95f2
commit 5cf3f82e06
No known key found for this signature in database
GPG Key ID: 69D6CE281FCAE663
14 changed files with 145 additions and 71 deletions

12
package-lock.json generated
View File

@ -1,19 +1,19 @@
{ {
"name": "@codex-storage/marketplace-ui-components", "name": "@codex-storage/marketplace-ui-components",
"version": "0.0.31", "version": "0.0.32",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@codex-storage/marketplace-ui-components", "name": "@codex-storage/marketplace-ui-components",
"version": "0.0.31", "version": "0.0.32",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"lucide-react": "^0.453.0" "lucide-react": "^0.453.0"
}, },
"devDependencies": { "devDependencies": {
"@chromatic-com/storybook": "^2.0.2", "@chromatic-com/storybook": "^2.0.2",
"@codex-storage/sdk-js": "^0.0.14", "@codex-storage/sdk-js": "^0.0.15",
"@storybook/addon-essentials": "^8.2.9", "@storybook/addon-essentials": "^8.2.9",
"@storybook/addon-interactions": "^8.2.9", "@storybook/addon-interactions": "^8.2.9",
"@storybook/addon-links": "^8.2.9", "@storybook/addon-links": "^8.2.9",
@ -619,9 +619,9 @@
} }
}, },
"node_modules/@codex-storage/sdk-js": { "node_modules/@codex-storage/sdk-js": {
"version": "0.0.14", "version": "0.0.15",
"resolved": "https://registry.npmjs.org/@codex-storage/sdk-js/-/sdk-js-0.0.14.tgz", "resolved": "https://registry.npmjs.org/@codex-storage/sdk-js/-/sdk-js-0.0.15.tgz",
"integrity": "sha512-zZcbFKQxxL3dlxjm77jKzOobYB8Z/oUozG5VVU4+hrAO2qlnERq9wQO2QgfnNB1LxaZeoN+Rb8kZrKc7Y1Jvmw==", "integrity": "sha512-asL59uhHNI2zPLEcygh6HnZEdQJebSjU2JXut6xZxAI87VVkWfN9Y1BxlyxgsF+wJF10DB0tnv3cPEI3wb2huQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"valibot": "^0.32.0" "valibot": "^0.32.0"

View File

@ -5,7 +5,7 @@
"type": "git", "type": "git",
"url": "https://github.com/codex-storage/codex-marketplace-ui-components" "url": "https://github.com/codex-storage/codex-marketplace-ui-components"
}, },
"version": "0.0.31", "version": "0.0.32",
"type": "module", "type": "module",
"scripts": { "scripts": {
"prepack": "npm run build", "prepack": "npm run build",
@ -41,7 +41,7 @@
"postcss-nesting": "^13.0.1" "postcss-nesting": "^13.0.1"
}, },
"devDependencies": { "devDependencies": {
"@codex-storage/sdk-js": "^0.0.14", "@codex-storage/sdk-js": "^0.0.15",
"@chromatic-com/storybook": "^2.0.2", "@chromatic-com/storybook": "^2.0.2",
"@storybook/addon-essentials": "^8.2.9", "@storybook/addon-essentials": "^8.2.9",
"@storybook/addon-interactions": "^8.2.9", "@storybook/addon-interactions": "^8.2.9",

View File

@ -37,6 +37,8 @@ type Props = {
* Apply custom classname. * Apply custom classname.
*/ */
className?: string; className?: string;
size?: "medium" | "small";
}; };
export function Button({ export function Button({
@ -45,6 +47,7 @@ export function Button({
Icon, Icon,
onMouseEnter, onMouseEnter,
onMouseLeave, onMouseLeave,
size = "medium",
fetching = false, fetching = false,
disabled = false, disabled = false,
variant = "primary", variant = "primary",
@ -55,7 +58,7 @@ export function Button({
onClick={onClick} onClick={onClick}
onMouseEnter={onMouseEnter} onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave} onMouseLeave={onMouseLeave}
className={`button ${className} button--${variant}`} className={`button ${className} button--${variant} button--${size}`}
{...attributes({ {...attributes({
disabled: disabled || fetching, disabled: disabled || fetching,
"aria-disabled": disabled || fetching, "aria-disabled": disabled || fetching,

View File

@ -1,17 +1,29 @@
.button { .button {
border-radius: var(--codex-border-radius); &.button--medium {
--codex-button-padding: 9px 10px;
}
&.button--small {
--codex-button-padding: 6px 10px;
}
border-radius: 8px;
outline: none; outline: none;
padding: 0.75rem 1.5rem; padding: var(--codex-button-padding);
display: flex; display: flex;
place-items: center; place-items: center;
gap: 0.75rem; gap: 2px;
font-weight: 500; font-weight: 500;
position: relative; position: relative;
border: none; border: none;
transition: transition:
box-shadow 0.35s, box-shadow 0.35s,
opacity 0.35s; opacity 0.35s;
font-family: var(--codex-font-family); font-family: Inter;
font-size: 14px;
font-weight: 500;
line-height: 20px;
letter-spacing: -0.006em;
border: 1px solid transparent; border: 1px solid transparent;
place-content: center; place-content: center;
@ -77,9 +89,8 @@
&.button--outline { &.button--outline {
color: var(--codex-color-outline, var(--codex-color-contrast)); color: var(--codex-color-outline, var(--codex-color-contrast));
border-color: var(--codex-border-color); border-color: var(--codex-border-color);
border-width: 1px; background-color: #2f2f2f;
border-style: solid; color: #969696;
background-color: transparent;
} }
span { span {

View File

@ -1,19 +1,9 @@
import { ReactNode } from "react";
import "./card.css"; import "./card.css";
type Props = { type Props = {
children: ReactNode;
className?: string; className?: string;
title: string;
}; };
export function Card({ children, className = "", title }: Props) { export function Card({ className = "" }: Props) {
return ( return <div className={`card ${className}`}>{}</div>;
<div className={`card ${className}`}>
<header>{title}</header>
<div>{children}</div>
</div>
);
} }

View File

@ -1,17 +1,20 @@
.card { .card {
border-radius: var(--codex-border-radius); border: 1px solid #96969633;
border: 1px solid var(--codex-border-color); border-radius: 16px;
font-family: var(--codex-font-family); padding: 16px;
background-color: var(--codex-background-secondary);
header { header {
border-bottom: 1px solid var(--codex-border-color); display: flex;
padding: 1rem 1.5rem; align-items: center;
font-size: 1.15rem; justify-content: space-between;
font-weight: bold; gap: 16px;
}
div { h5 {
padding: 1.5rem; font-family: Inter;
font-size: 16px;
font-weight: 500;
line-height: 24px;
letter-spacing: -0.011em;
}
} }
} }

View File

@ -38,6 +38,8 @@ type Props = {
inputClassName?: string; inputClassName?: string;
inputContainerClassName?: string; inputContainerClassName?: string;
size?: "big" | "medium";
} & InputHTMLAttributes<HTMLInputElement>; } & InputHTMLAttributes<HTMLInputElement>;
export const Input = forwardRef<HTMLInputElement, Props>( export const Input = forwardRef<HTMLInputElement, Props>(
@ -49,6 +51,7 @@ export const Input = forwardRef<HTMLInputElement, Props>(
style, style,
Icon, Icon,
inputClassName, inputClassName,
size = "big",
inputContainerClassName = "", inputContainerClassName = "",
disabled = false, disabled = false,
onChange, onChange,
@ -74,6 +77,7 @@ export const Input = forwardRef<HTMLInputElement, Props>(
["input"], ["input"],
["input--invalid", invalid || isInvalid], ["input--invalid", invalid || isInvalid],
["input--icon", !!Icon], ["input--icon", !!Icon],
["input--" + size],
[inputClassName || ""] [inputClassName || ""]
)} )}
> >

View File

@ -1,4 +1,12 @@
.input { .input {
&.input--big {
--codex-input-height: 64px;
}
&.input--medium {
--codex-input-height: 40px;
}
input { input {
background-color: var(--codex-input-background); background-color: var(--codex-input-background);
color: white; color: white;
@ -10,8 +18,21 @@
box-sizing: border-box; box-sizing: border-box;
font-weight: 500; font-weight: 500;
font-size: 20px; font-size: 20px;
height: 64px; height: var(--codex-input-height);
position: relative; position: relative;
font-family: Inter;
font-size: 14px;
font-weight: 400;
line-height: 20px;
letter-spacing: -0.006em;
&::placeholder {
font-family: Inter;
font-size: 14px;
font-weight: 400;
line-height: 20px;
letter-spacing: -0.006em;
}
} }
&.input--invalid input { &.input--invalid input {

View File

@ -1,4 +1,3 @@
import { PrettyBytes } from "../utils/bytes";
import "./spaceAllocation.css"; import "./spaceAllocation.css";
export type SpaceAllocationItem = { export type SpaceAllocationItem = {
@ -38,13 +37,13 @@ export function SpaceAllocation({ data }: Props) {
))} ))}
</header> </header>
<ul className="nodeSpaceAllocation-legend"> <ul>
{data.map((d) => ( {data.map((d) => (
<li key={d.title}> <li key={d.title}>
<span style={{ backgroundColor: d.color }}></span> <span style={{ backgroundColor: d.color }}></span>
<p> <p>
<span>{d.title}</span> <span>{d.title}</span>
<small> {PrettyBytes(d.size)}</small> {/* <small> {PrettyBytes(d.size)}</small> */}
</p> </p>
</li> </li>
))} ))}

View File

@ -1,20 +1,25 @@
.space-allocation { .space-allocation {
header { header {
height: 10px; height: 26px;
display: flex; display: flex;
gap: 0.75rem; gap: 5px;
margin-bottom: 0.5rem; margin-bottom: 16px;
span { span {
display: inline-block; display: inline-block;
height: 100%; height: 100%;
border-radius: var(--codex-border-radius); border-radius: 4px;
height: 26px;
font-family: Inter;
font-size: 12px;
font-weight: 400;
line-height: 16px;
} }
} }
ul { ul {
display: flex; display: flex;
gap: 0.75rem; gap: 16px;
flex-wrap: wrap; flex-wrap: wrap;
padding-left: 0; padding-left: 0;
@ -22,15 +27,16 @@
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
gap: 0.5rem; gap: 4px;
> span { > span {
width: 1rem; width: 9px;
height: 1rem; height: 9px;
border-radius: var(--codex-border-radius); border-radius: 50%;
border: 2px solid #0e121b;
} }
p { /* p {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
line-height: 1rem; line-height: 1rem;
@ -40,7 +46,7 @@
small { small {
color: var(--codex-input-label-color); color: var(--codex-input-label-color);
} }
} } */
} }
} }
} }

View File

@ -1,12 +1,11 @@
import { FileStack, Upload as UploadIcon } from "lucide-react";
import { ChangeEvent, DragEventHandler, useRef } from "react"; import { ChangeEvent, DragEventHandler, useRef } from "react";
import { attributes } from "../utils/attributes.ts"; import { attributes } from "../utils/attributes.ts";
import "./upload.css"; import "./upload.css";
import { UploadFile } from "./UploadFile.tsx"; import { UploadFile } from "./UploadFile.tsx";
import { useUploadStategy } from "./useUploadStrategy.ts"; import { useUploadStategy } from "./useUploadStrategy.ts";
import { classnames } from "../utils/classnames.ts"; import { classnames } from "../utils/classnames.ts";
import { ButtonIcon } from "../ButtonIcon/ButtonIcon.tsx";
import { CodexData } from "@codex-storage/sdk-js"; import { CodexData } from "@codex-storage/sdk-js";
import { UploadIcon } from "./UploadIcon.tsx";
type Props = { type Props = {
/** /**
@ -118,7 +117,7 @@ export function Upload({
return ( return (
<> <>
<div <div
className={classnames(["upload"], ["upload-warning", !!warning])} className={classnames(["upload"], ["upload--warning", !!warning])}
tabIndex={1} tabIndex={1}
onClick={onInternalClick} onClick={onInternalClick}
onDragOver={onDragPrevents} onDragOver={onDragPrevents}
@ -127,16 +126,19 @@ export function Upload({
onMouseEnter={onMouseEnter} onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave} onMouseLeave={onMouseLeave}
> >
<ButtonIcon Icon={multiple ? FileStack : UploadIcon}></ButtonIcon> <div>
<p>
<b> <b>
Drop your {multiple ? "file(s)" : "file"} here or{" "} Drop your {multiple ? "file(s)" : "file"} here or{" "}
<span>browse</span> <span>browse</span>
</b> </b>
</p>
<small> {multiple ? "Up to 10 files" : "Choose one single file"}</small> <small>
{" "}
{multiple ? "Up to 10 files" : "Choose one single file"}
</small>
</div>
<UploadIcon></UploadIcon>
<input <input
data-testid="upload" data-testid="upload"

View File

@ -0,0 +1,20 @@
type Props = {
width?: number;
fill?: string;
};
export function UploadIcon({ width = 30, fill = "#96969666" }: Props) {
return (
<svg
width={width}
viewBox="0 0 30 28"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M15.621 3.5H28.5C28.8978 3.5 29.2794 3.65804 29.5607 3.93934C29.842 4.22064 30 4.60218 30 5V26C30 26.3978 29.842 26.7794 29.5607 27.0607C29.2794 27.342 28.8978 27.5 28.5 27.5H1.5C1.10218 27.5 0.720644 27.342 0.43934 27.0607C0.158035 26.7794 0 26.3978 0 26V2C0 1.60218 0.158035 1.22064 0.43934 0.93934C0.720644 0.658035 1.10218 0.5 1.5 0.5H12.621L15.621 3.5ZM3 3.5V24.5H27V6.5H14.379L11.379 3.5H3ZM16.5 15.5V21.5H13.5V15.5H9L15 9.5L21 15.5H16.5Z"
fill={fill}
/>
</svg>
);
}

View File

@ -6,26 +6,40 @@
); );
min-height: 150px; min-height: 150px;
border-radius: var(--codex-border-radius); border-radius: var(--codex-border-radius);
justify-content: center; justify-content: space-between;
flex-direction: column; align-items: center;
gap: 0.5rem; gap: 0.5rem;
cursor: pointer; cursor: pointer;
padding: 0.5rem 2rem; padding: 0.5rem 2rem;
display: flex; display: flex;
align-items: center;
p { b {
margin-bottom: 0; font-family: Inter;
margin-top: 12px; font-size: 16px;
line-height: 4px; font-weight: 400;
line-height: 24px;
letter-spacing: -0.011em;
display: block;
span { span {
color: var(--codex-color-primary); color: var(--codex-color-primary);
border-bottom: 1px solid var(--codex-color-primary);
font-family: Inter;
font-size: 16px;
font-weight: 600;
line-height: 24px;
letter-spacing: -0.011em;
} }
} }
small { small {
color: var(--codex-input-label-color); font-family: Inter;
font-size: 14px;
font-weight: 400;
line-height: 20px;
letter-spacing: -0.006em;
text-align: left;
color: #969696;
} }
input + span { input + span {

View File

@ -2,7 +2,8 @@ export { Button } from "./components/Button/Button";
export { ButtonIcon } from "./components/ButtonIcon/ButtonIcon"; export { ButtonIcon } from "./components/ButtonIcon/ButtonIcon";
export { Input } from "./components/Input/Input"; export { Input } from "./components/Input/Input";
export { InputGroup } from "./components/InputGroup/InputGroup"; export { InputGroup } from "./components/InputGroup/InputGroup";
export { Upload } from "./components/Upload/Upload"; export * from "./components/Upload/Upload";
export { UploadIcon } from "./components/Upload/UploadIcon";
export { Card } from "./components/Card/Card"; export { Card } from "./components/Card/Card";
export { Select } from "./components/Select/Select"; export { Select } from "./components/Select/Select";
export { Toast } from "./components/Toast/Toast"; export { Toast } from "./components/Toast/Toast";