Skip to content

Commit

Permalink
Merge pull request #19 from NJUPT-SAST/dev-bqx
Browse files Browse the repository at this point in the history
Dev bqx
  • Loading branch information
MaxtuneLee authored Mar 27, 2024
2 parents cad2c7d + 9af1ee1 commit e898f2c
Show file tree
Hide file tree
Showing 14 changed files with 280 additions and 129 deletions.
2 changes: 1 addition & 1 deletion .lintstagedrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default {
"git add ."
],
"packages/ui-react/**/*.{js,cjs,ts,html,json,css,scss,tsx,sass}": () => [
"pnpm --filter @sast/ui-react test",
// "pnpm --filter @sast/ui-react test",
"pnpm --filter @sast/ui-react format",
"pnpm --filter @sast/ui-react lint",
"git add ."
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-react/coverage/Button.tsx.html
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ <h1><a href="index.html">All files</a> Button.tsx</h1>
rel="noopener noreferrer"
>istanbul</a
>
at 2024-03-24T12:19:31.987Z
at 2024-03-24T10:42:31.792Z
</div>
<script src="prettify.js"></script>
<script>
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-react/coverage/clover.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<coverage generated="1711282772007" clover="3.2.0">
<project timestamp="1711282772008" name="All files">
<coverage generated="1711276951819" clover="3.2.0">
<project timestamp="1711276951820" name="All files">
<metrics statements="64" coveredstatements="64" conditionals="3" coveredconditionals="1" methods="0" coveredmethods="0" elements="67" coveredelements="65" complexity="0" loc="64" ncloc="64" packages="1" files="1" classes="1"/>
<file name="Button.tsx" path="D:\Projects\SAST\SAST-UI\packages\ui-react\lib\Button\Button.tsx">
<metrics statements="64" coveredstatements="64" conditionals="3" coveredconditionals="1" methods="0" coveredmethods="0"/>
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-react/coverage/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ <h1>All files</h1>
rel="noopener noreferrer"
>istanbul</a
>
at 2024-03-24T12:19:31.987Z
at 2024-03-24T10:42:31.792Z
</div>
<script src="prettify.js"></script>
<script>
Expand Down
33 changes: 25 additions & 8 deletions packages/ui-react/lib/Badge/Badge.module.scss
Original file line number Diff line number Diff line change
@@ -1,30 +1,47 @@
@use '../_variables/color.scss' as *;
@use '../_variables/radius.scss' as *;
@use '../_variables/shadow.scss' as *;
@use '../_variables/duration.scss' as *;
@use '../_variables/animation.scss' as *;
@mixin color-badge($color-name) {
background-color: rgba(var(--#{$color-name}-color-background-rgb), 1);
color: var(--#{$color-name}-color);
background-color: $color-name;
color: $white-color;
font-weight: bold;
}

.base {
padding: 3px 10px;
border-radius: 5px;
border-radius: $radius-5;
@include shadow;
transition: all $duration-100 $cubic-bezier;
&:hover {
opacity: 0.8;
}
&.info {
@include color-badge(primary);
@include color-badge($primary-color);
}
&.success {
@include color-badge(success);
@include color-badge($success-color);
}
&.warning {
@include color-badge(warning);
@include color-badge($warning-color);
}
&.error {
@include color-badge(danger);
@include color-badge($danger-color);
}
&.ghost {
@include color-badge($pale-white-color);
color: $black-color;
}
&.medium {
font-size: 14px;
padding: 2px 11px;
}
&.large {
font-size: 18px;
padding: 3px 14px;
}
&.small {
font-size: 10px;
padding: 2px 8px;
}
}
2 changes: 1 addition & 1 deletion packages/ui-react/lib/Badge/Badge.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const meta = {
control: { type: 'select' },
},
type: {
options: ['info', 'success', 'warning', 'error'],
options: ['info', 'success', 'warning', 'error', 'ghost'],
control: { type: 'select' },
},
},
Expand Down
31 changes: 28 additions & 3 deletions packages/ui-react/lib/Badge/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface BadgeProps {
/**
* the type of the Badge
*/
type?: 'info' | 'success' | 'warning' | 'error';
type?: 'info' | 'success' | 'warning' | 'error' | 'ghost';
/**
* the size of the Badge
*/
Expand All @@ -19,11 +19,36 @@ export interface BadgeProps {
* is clickCopy work?
*/
clickCopy?: boolean;
/**
* The shadow of the button.
*/
shadow?: 'regular' | 'small' | 'medium' | 'large' | 'extraLarge' | 'inner' | 'none';
/**
* classname , the classname of the badge
*/
className?: string;
}

export const Badge = React.forwardRef<HTMLDivElement, BadgeProps>(
({ type = 'info', size = 'medium', content = 'hello', clickCopy = false, ...rest }, ref) => {
const badgeClass = classNames(styles['base'], styles[type], styles[size]);
(
{
type = 'info',
size = 'medium',
content = 'hello',
clickCopy = false,
shadow = 'none',
className,
...rest
},
ref,
) => {
const badgeClass = classNames(
styles['base'],
styles[type],
styles[size],
styles[`shadow-${shadow}`],
className,
);

const handleBadge = () => {
navigator.clipboard.writeText(content);
Expand Down
23 changes: 12 additions & 11 deletions packages/ui-react/lib/Button/Button.module.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
@use '../variables' as *;
@use '../_variables/color.scss' as *;
.base {
background-color: var(--primary-color);
color: var(--white-color);
background-color: $primary-color;
color: $white-color;
padding: 10px;
border-radius: 5px;
border: none;
Expand All @@ -17,17 +18,17 @@
transform: scale(0.98);
}
&.primary {
background-color: var(--primary-color);
background-color: $primary-color;
}
&.secondary {
background-color: var(--white-color);
color: var(--primary-color);
border: 1px solid var(--primary-color);
background-color: $white-color;
color: $primary-color;
border: 1px solid $primary-color;
}
&.border {
border: solid 1px var(--border-white);
background-color: var(--white-color);
color: var(--black-color);
border: solid 1px $border-white-color;
background-color: $white-color;
color: $black-color;
font-weight: 500;
}
&.ghost {
Expand All @@ -36,11 +37,11 @@
backdrop-filter: brightness(0.97);
}
background-color: transparent;
color: var(--primary-color);
color: $primary-color;
font-weight: 600;
}
&.danger {
background-color: var(--danger-color);
background-color: $danger-color;
}
&.disabled {
cursor: not-allowed;
Expand Down
7 changes: 7 additions & 0 deletions packages/ui-react/lib/Dialog/Dialog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,19 @@ import { Button } from '../Button';

export const ShowDialog = () => {
const [visible, setVisible] = useState(false);
const [sonVisible, setSonVisible] = useState(false);
return (
<>
<Button onClick={() => setVisible(true)}>Show Dialog</Button>
<Dialog
visible={visible}
onCancel={() => setVisible(false)}
onOk={() => setSonVisible(true)}
maskClosable={false}
/>
<Dialog
visible={sonVisible}
onCancel={() => setSonVisible(false)}
/>
</>
);
Expand Down
120 changes: 74 additions & 46 deletions packages/ui-react/lib/Dialog/Dialog.module.scss
Original file line number Diff line number Diff line change
@@ -1,72 +1,100 @@
@use '../variables' as *;
@use '../_variables/shadow.scss' as *;
@use '../_variables/animation.scss' as *;
@use '../_variables/color.scss' as *;

@property --blur {
syntax: '<length>';
inherits: false;
initial-value: 0px;
}

@property --opacity-background {
syntax: '<percentage>';
inherits: false;
initial-value: 0%;
}

@property --opacity-card {
syntax: '<percentage>';
inherits: false;
initial-value: 0%;
}

@property --scale {
syntax: '<percentage>';
inherits: false;
initial-value: 80%;
}

@mixin animation($name) {
animation-name: $name;
animation-duration: 400ms;
animation-duration: 500ms;
animation-timing-function: $cubic-bezier;
animation-fill-mode: forwards;
}

.background {
top: 0;
left: 0;
@mixin dialog-animation() {
&.dialog-in {
@include animation(dialog-in);
}
&.dialog-hide {
@include animation(dialog-hide);
}
}

.dialog-container {
height: 100%;
width: 100%;
left: 0;
top: 0;
position: absolute;
box-sizing: border-box;
background-color: $background-shadow-color;
&.background-in {
@include animation(in);
&.mask {
background-color: rgb($black-color, var(--opacity-background));
backdrop-filter: blur(var(--blur));
}
&.background-hide {
@include animation(hide);
&.no-mask {
all: unset;
}
.base {
@include absolute-center;
&.in {
@include animation(dialog-in);
}
&.hide {
@include animation(dialog-hide);
}
@include dialog-animation();
.dialog {
z-index: 1;
position: absolute;
top: 50%;
transform: translateY(-50%);
padding: 0;
border: none;
border-radius: 8px;
scale: var(--scale);
opacity: var(--opacity-card);
@include dialog-animation();
}
}

@keyframes dialog-in {
0% {
opacity: 0;
transform: translate(-50%, -50%) scale(0.8);
--blur: 0px;
--opacity-background: 0%;
--opacity-card: 0%;
--scale: 70%;
}
100% {
opacity: 1;
transform: translate(-50%, -50%) scale(1);
--blur: 4px;
--opacity-background: 40%;
--opacity-card: 100%;
--scale: 100%;
}
}

@keyframes dialog-hide {
0% {
opacity: 1;
transform: translate(-50%, -50%) scale(1);
}
100% {
opacity: 0;
transform: translate(-50%, -50%) scale(0.8);
}
}

@keyframes in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}

@keyframes hide {
0% {
opacity: 1;
--blur: 4px;
--opacity-background: 40%;
--opacity-card: 100%;
--scale: 100%;
}
100% {
opacity: 0;
--blur: 0px;
--opacity-background: 0%;
--opacity-card: 0%;
--scale: 80%;
}
}
Loading

0 comments on commit e898f2c

Please sign in to comment.