@spark-ui/badge 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/LICENSE +21 -0
- package/dist/Badge.d.ts +6 -0
- package/dist/BadgeItem.d.ts +25 -0
- package/dist/BadgeItem.styles.d.ts +7 -0
- package/dist/config.d.ts +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +13 -0
- package/package.json +35 -0
- package/tsconfig.json +4 -0
- package/vite.config.ts +6 -0
package/CHANGELOG.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
|
+
|
6
|
+
# 0.1.0 (2023-05-09)
|
7
|
+
|
8
|
+
### Bug Fixes
|
9
|
+
|
10
|
+
- **badge:** apply some new agreements like for the aria-label ([8cd2b72](https://github.com/adevinta/spark/commit/8cd2b72d632e2f4ea6884cda9b4a114e2bed62f7))
|
11
|
+
- **badge:** fix types ([71ddf42](https://github.com/adevinta/spark/commit/71ddf42c786c142441cb6b35c49f8932ffa2f113))
|
12
|
+
- **badge:** fix types ([3a71a7f](https://github.com/adevinta/spark/commit/3a71a7f5528801be78424fcac9245475f3ac2c1e))
|
13
|
+
- **badge:** fix types ([9ba5b3b](https://github.com/adevinta/spark/commit/9ba5b3b3956b7632034703ad98f1acbcd2504b30))
|
14
|
+
- **badge:** pass classname prop ([b72f4a7](https://github.com/adevinta/spark/commit/b72f4a7331ae245782c8b3ad06deda5fc13a9e07))
|
15
|
+
|
16
|
+
### Features
|
17
|
+
|
18
|
+
- **badge:** adapt styles to design specs ([e7ffded](https://github.com/adevinta/spark/commit/e7ffded6231272f383d74ab5e06a80c2f6535e12))
|
19
|
+
- **badge:** add code suggestions ([266f99f](https://github.com/adevinta/spark/commit/266f99f716a93c11007af4b56a941576203ff500))
|
20
|
+
- **badge:** add first changes ([45ffb3d](https://github.com/adevinta/spark/commit/45ffb3d75f49a7becc0a7f05809e27e4d1d00729))
|
21
|
+
- **badge:** apply code suggestions and fixes ([7675009](https://github.com/adevinta/spark/commit/7675009488c89c30fce01241c480901d115a4245))
|
22
|
+
- **badge:** apply final intents ([bb5963a](https://github.com/adevinta/spark/commit/bb5963a5845b4b29aa19ec0bfc0696521ff8f31f))
|
23
|
+
- **badge:** implement accessibility specs ([0875116](https://github.com/adevinta/spark/commit/087511607515c13bafeac0affc365395d7e34c64))
|
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) Adevinta ASA.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/dist/Badge.d.ts
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
2
|
+
import { BadgeItemProps } from './BadgeItem';
|
3
|
+
export type BadgeProps = PropsWithChildren<Omit<BadgeItemProps, 'type'>>;
|
4
|
+
export declare const Badge: import("react").ForwardRefExoticComponent<Omit<BadgeItemProps, "type"> & {
|
5
|
+
children?: import("react").ReactNode;
|
6
|
+
} & import("react").RefAttributes<HTMLElement>>;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { HTMLAttributes, PropsWithRef } from 'react';
|
2
|
+
import { type StylesProps } from './BadgeItem.styles';
|
3
|
+
export interface BadgeItemProps extends PropsWithRef<Omit<HTMLAttributes<HTMLSpanElement>, 'aria-label'>>, StylesProps {
|
4
|
+
/**
|
5
|
+
* Numeric value used as indicator inside the component.
|
6
|
+
*/
|
7
|
+
count?: number;
|
8
|
+
/**
|
9
|
+
* Maximum numeric value to be dispayed as a count value.
|
10
|
+
*/
|
11
|
+
overflowCount?: number;
|
12
|
+
/**
|
13
|
+
* A custom label for accessibility purposes. It can also be defined as a builder function
|
14
|
+
* to handle dynamic inner data to create a custom label.
|
15
|
+
*/
|
16
|
+
'aria-label'?: string | (({ count, overflowCount }: {
|
17
|
+
count?: number;
|
18
|
+
overflowCount?: number;
|
19
|
+
}) => string);
|
20
|
+
/**
|
21
|
+
* Describes the way the component is displayed: relative to another element or just standalone.
|
22
|
+
*/
|
23
|
+
type?: 'relative' | 'standalone';
|
24
|
+
}
|
25
|
+
export declare const BadgeItem: import("react").ForwardRefExoticComponent<BadgeItemProps & import("react").RefAttributes<HTMLSpanElement>>;
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { type VariantProps } from 'class-variance-authority';
|
2
|
+
export declare const styles: (props?: ({
|
3
|
+
intent?: "primary" | "secondary" | "success" | "alert" | "danger" | "info" | "neutral" | "surface" | null | undefined;
|
4
|
+
size?: "sm" | "md" | null | undefined;
|
5
|
+
type?: "relative" | "standalone" | null | undefined;
|
6
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
7
|
+
export type StylesProps = VariantProps<typeof styles>;
|
package/dist/config.d.ts
ADDED
package/dist/index.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './Badge';
|
package/dist/index.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),y=require("class-variance-authority");Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Object.freeze(Object.defineProperty({__proto__:null,designs:["filled","outlined","tinted","ghost","contrast"],intents:["current","primary","secondary","success","error","info","alert","danger","neutral","surface"],shapes:["rounded","square","pill"],sizes:["current","sm","md","lg"]},Symbol.toStringTag,{value:"Module"}));const c="danger",d="relative",b=y.cva(["inline-flex h-fit","empty:p-none","text-center font-bold","rounded-full ring-2"],{variants:{intent:{primary:["bg-primary","text-on-primary","ring-on-primary"],secondary:["bg-secondary","text-on-secondary","ring-on-secondary"],success:["bg-success","text-on-success","ring-on-success"],alert:["bg-alert","text-on-alert","ring-on-alert"],danger:["bg-error","text-on-error","ring-on-error"],info:["bg-info","text-on-info","ring-on-info"],neutral:["bg-neutral","text-on-neutral","ring-on-neutral"],surface:["bg-surface","text-on-surface","ring-on-surface"]},size:{sm:["text-small","px-[var(--sz-6)] py-[var(--sz-2)]","empty:h-sz-12 empty:w-sz-12"],md:["text-caption","px-md py-sm","empty:h-sz-16 empty:w-sz-16"]},type:{relative:["relative -translate-x-2/4 -translate-y-2/4"],standalone:[]}},defaultVariants:{intent:c,size:"md",type:d}}),l=e.forwardRef(({intent:t=c,size:r="md",type:n=d,count:a,overflowCount:o=99,"aria-label":s,className:u,...m},f)=>{const p=a&&a>o,g={...m,"aria-label":typeof s=="function"?s({count:a,overflowCount:o}):s};return e.createElement("span",{ref:f,"data-spark-component":"badge",role:"status",className:b({intent:t,size:r,type:n,className:u}),...g},p?`${o}+`:a)});l.displayName="BadgeItem";const i=e.forwardRef(({children:t,...r},n)=>t?e.createElement("div",{className:"relative flex"},t,e.createElement(l,{ref:n,...r})):e.createElement(l,{ref:n,type:"standalone",...r}));i.displayName="Badge",exports.Badge=i;
|
package/dist/index.mjs
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
import a, { forwardRef as i } from "react";
|
2
|
+
import { cva as y } from "class-variance-authority";
|
3
|
+
Object.freeze(Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), Object.freeze(Object.defineProperty({ __proto__: null, designs: ["filled", "outlined", "tinted", "ghost", "contrast"], intents: ["current", "primary", "secondary", "success", "error", "info", "alert", "danger", "neutral", "surface"], shapes: ["rounded", "square", "pill"], sizes: ["current", "sm", "md", "lg"] }, Symbol.toStringTag, { value: "Module" }));
|
4
|
+
const c = "danger", d = "relative", b = y(["inline-flex h-fit", "empty:p-none", "text-center font-bold", "rounded-full ring-2"], { variants: { intent: { primary: ["bg-primary", "text-on-primary", "ring-on-primary"], secondary: ["bg-secondary", "text-on-secondary", "ring-on-secondary"], success: ["bg-success", "text-on-success", "ring-on-success"], alert: ["bg-alert", "text-on-alert", "ring-on-alert"], danger: ["bg-error", "text-on-error", "ring-on-error"], info: ["bg-info", "text-on-info", "ring-on-info"], neutral: ["bg-neutral", "text-on-neutral", "ring-on-neutral"], surface: ["bg-surface", "text-on-surface", "ring-on-surface"] }, size: { sm: ["text-small", "px-[var(--sz-6)] py-[var(--sz-2)]", "empty:h-sz-12 empty:w-sz-12"], md: ["text-caption", "px-md py-sm", "empty:h-sz-16 empty:w-sz-16"] }, type: { relative: ["relative -translate-x-2/4 -translate-y-2/4"], standalone: [] } }, defaultVariants: { intent: c, size: "md", type: d } }), l = i(({ intent: e = c, size: t = "md", type: r = d, count: n, overflowCount: o = 99, "aria-label": s, className: m, ...p }, u) => {
|
5
|
+
const f = n && n > o, g = { ...p, "aria-label": typeof s == "function" ? s({ count: n, overflowCount: o }) : s };
|
6
|
+
return a.createElement("span", { ref: u, "data-spark-component": "badge", role: "status", className: b({ intent: e, size: t, type: r, className: m }), ...g }, f ? `${o}+` : n);
|
7
|
+
});
|
8
|
+
l.displayName = "BadgeItem";
|
9
|
+
const x = i(({ children: e, ...t }, r) => e ? a.createElement("div", { className: "relative flex" }, e, a.createElement(l, { ref: r, ...t })) : a.createElement(l, { ref: r, type: "standalone", ...t }));
|
10
|
+
x.displayName = "Badge";
|
11
|
+
export {
|
12
|
+
x as Badge
|
13
|
+
};
|
package/package.json
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
{
|
2
|
+
"name": "@spark-ui/badge",
|
3
|
+
"version": "0.1.0",
|
4
|
+
"description": "Badge component is a visual indicator for numeric values such as tallies and scores.",
|
5
|
+
"publishConfig": {
|
6
|
+
"access": "public"
|
7
|
+
},
|
8
|
+
"main": "./dist/index.js",
|
9
|
+
"module": "./dist/index.mjs",
|
10
|
+
"types": "./dist/index.d.ts",
|
11
|
+
"scripts": {
|
12
|
+
"build": "vite build"
|
13
|
+
},
|
14
|
+
"peerDependencies": {
|
15
|
+
"react": "^16.8 || ^17.0 || ^18.0",
|
16
|
+
"react-dom": "^16.8 || ^17.0 || ^18.0",
|
17
|
+
"tailwindcss": "^3.0.0"
|
18
|
+
},
|
19
|
+
"repository": {
|
20
|
+
"type": "git",
|
21
|
+
"url": "git@github.com:adevinta/spark.git",
|
22
|
+
"directory": "packages/components/badge"
|
23
|
+
},
|
24
|
+
"devDependencies": {
|
25
|
+
"@spark-ui/icon": "1",
|
26
|
+
"@spark-ui/icons": "1",
|
27
|
+
"@spark-ui/radio": "1"
|
28
|
+
},
|
29
|
+
"bugs": {
|
30
|
+
"url": "https://github.com/adevinta/spark/issues"
|
31
|
+
},
|
32
|
+
"homepage": "https://sparkui.vercel.app",
|
33
|
+
"license": "MIT",
|
34
|
+
"gitHead": "a6d74d7b4702f93fcc9fe9bc382337ec07067699"
|
35
|
+
}
|
package/tsconfig.json
ADDED