-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
25137ac
commit 872335b
Showing
20 changed files
with
971 additions
and
674 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,6 @@ | |
"index", | ||
"button", | ||
"accordion", | ||
"input" | ||
"input", | ||
"badge" | ||
] |
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,56 @@ | ||
import { Badge } from "@sast/ui-universal"; | ||
import Wraper from '../../tools/wraper/index' | ||
|
||
|
||
# Badge Component | ||
|
||
The Badge component displays a small status descriptor for an element. | ||
|
||
<Wraper> | ||
<Badge content="New" type="info" size="medium" /> | ||
</Wraper> | ||
|
||
## Usage | ||
|
||
```jsx | ||
import { Badge } from "@sast/ui-universal"; | ||
|
||
export default function App() { | ||
return <Badge content="New" type="info" size="medium" />; | ||
} | ||
``` | ||
|
||
## Props | ||
|
||
| Property | Description | Type | Default | | ||
|-------------|---------------------------------------------------------|---------------------------|---------| | ||
| `type` | The type of the badge (info, success, warning, error). | `"info" \| "success" \| "warning" \| "error"` | `"info"` | | ||
| `size` | The size of the badge (small, medium, large). | `"small" \| "medium" \| "large"` | `"medium"` | | ||
| `content` | The content of the badge. | `string` | `"hello"` | | ||
| `clickCopy` | Determines whether clicking on the badge copies its content to the clipboard. | `boolean` | `false` | | ||
|
||
### Events | ||
|
||
- `clickCopy`: Fired when the `clickCopy` prop is `true` and the badge is clicked. Copies the badge content to the clipboard. | ||
|
||
### Example | ||
|
||
```jsx playground direction=vertical | ||
import { Badge } from "@sast/ui-universal"; | ||
|
||
export default function Example() { | ||
const handleCopy = () => { | ||
console.log("Badge content copied!"); | ||
}; | ||
|
||
return ( | ||
<Badge | ||
content="New" | ||
type="info" | ||
size="small" | ||
clickCopy={true} | ||
onClickCopy={handleCopy} | ||
/> | ||
); | ||
} | ||
``` |
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
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 @@ | ||
$cubic-bezier: cubic-bezier(0.215, 0.61, 0.355, 1); |
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,4 @@ | ||
// border width variables | ||
$border-0: 0px; | ||
$border-1: 1px; | ||
$border-2: 2px; |
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,10 @@ | ||
//color variables | ||
$primary-color: #0078d4; | ||
$secondary-color: #71afe5; | ||
$danger-color: #ff0000; | ||
$warning-color: #ffb900; | ||
$success-color: #00c853; | ||
$white-color: #ffffff; | ||
$pale-white-color: #fcfcfc; | ||
$black-color: #121212; | ||
$gray-color: #808080; |
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,5 @@ | ||
//disabled | ||
@mixin disabled { | ||
cursor: not-allowed; | ||
opacity: 0.4; | ||
} |
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,6 @@ | ||
//animation-duration varibles | ||
$duration-100: 100ms; | ||
$duration-200: 200ms; | ||
$duration-300: 300ms; | ||
$duration-400: 400ms; | ||
$duration-800: 800ms; |
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,6 @@ | ||
//font-size variables | ||
$font-size-8: 8px; | ||
$font-size-10: 10px; | ||
$font-size-12: 12px; | ||
$font-size-14: 14px; | ||
$font-size-16: 16px; |
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,6 @@ | ||
//border radius variables | ||
$radius-10: 10px; | ||
$radius-8: 8px; | ||
$radius-5: 5px; | ||
$radius-15: 15px; | ||
$radius-half: 50%; |
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,32 @@ | ||
@mixin color-badge($color-name) { | ||
background-color: rgba(var(--#{$color-name}-color-background-rgb), 1); | ||
color: var(--#{$color-name}-color); | ||
} | ||
|
||
.base { | ||
padding: 3px 10px; | ||
border-radius: 5px; | ||
width: fit-content; | ||
|
||
&.info { | ||
@include color-badge(primary); | ||
} | ||
&.success { | ||
@include color-badge(success); | ||
} | ||
&.warning { | ||
@include color-badge(warning); | ||
} | ||
&.error { | ||
@include color-badge(danger); | ||
} | ||
&.medium { | ||
font-size: 14px; | ||
} | ||
&.large { | ||
font-size: 18px; | ||
} | ||
&.small { | ||
font-size: 10px; | ||
} | ||
} |
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,65 @@ | ||
import { createComponent } from "@lit/react"; | ||
import { LitElement, html } from "lit"; | ||
import { customElement, property } from "lit/decorators.js"; | ||
import { classMap } from "lit/directives/class-map.js"; | ||
import React from "react"; | ||
import styles from "./index.scss?inline"; | ||
|
||
export interface BadgeProps { | ||
/** | ||
* the type of the Badge | ||
*/ | ||
type?: "info" | "success" | "warning" | "error"; | ||
/** | ||
* the size of the Badge | ||
*/ | ||
size?: "small" | "medium" | "large"; | ||
/** | ||
* the content of the Badge | ||
*/ | ||
content: string; | ||
/** | ||
* is clickCopy work? | ||
*/ | ||
clickCopy?: boolean; | ||
} | ||
|
||
@customElement("a-badge") | ||
class ABadge extends LitElement { | ||
static styles = styles; | ||
@property({ type: String }) type: BadgeProps["type"] = "info"; | ||
@property({ type: String }) size: BadgeProps["size"] = "medium"; | ||
@property({ type: String }) content: BadgeProps["content"] = "hello"; | ||
@property({ type: Boolean }) clickCopy: BadgeProps["clickCopy"] = false; | ||
|
||
render() { | ||
return html` | ||
<div | ||
class="base ${classMap({ | ||
base: true, | ||
[this.type as string]: true, | ||
[this.size as string]: true, | ||
})}" | ||
@click=${this.clickCopy ? this.handleBadge : undefined} | ||
> | ||
<span>${this.content}</span> | ||
</div> | ||
`; | ||
} | ||
|
||
handleBadge() { | ||
navigator.clipboard.writeText(this.content); | ||
} | ||
} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
"a-badge": ABadge; | ||
} | ||
} | ||
|
||
export const Badge = createComponent({ | ||
tagName: "a-badge", | ||
elementClass: ABadge, | ||
react: React, | ||
}); |
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
Oops, something went wrong.