-
Notifications
You must be signed in to change notification settings - Fork 663
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #247 from hepengwei/feat_he
新增角向渐变圆环
- Loading branch information
Showing
8 changed files
with
123 additions
and
7 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
src/pages/html/VisualDesign/components/ActivityCountDown/index.module.scss
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
56 changes: 56 additions & 0 deletions
56
src/pages/html/VisualDesign/components/ConicGradientRing/index.module.scss
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 @@ | ||
.container { | ||
width: 100%; | ||
height: 450px; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
|
||
$boxSize: 300px; | ||
$ringHeight: 46px; | ||
.box { | ||
width: $boxSize; | ||
height: $boxSize; | ||
position: relative; | ||
animation: rotate 4s linear infinite; | ||
|
||
.item { | ||
box-sizing: border-box; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
border-radius: 50%; | ||
mask: radial-gradient( | ||
transparent, | ||
transparent calc($boxSize / 2 - $ringHeight), | ||
#000c17 calc($boxSize / 2 - $ringHeight + 1px), | ||
#000c17 100% | ||
); | ||
|
||
.semicircle { | ||
box-sizing: border-box; | ||
position: absolute; | ||
width: calc($ringHeight / 2); | ||
height: $ringHeight; | ||
top: 0; | ||
left: calc(50% - $ringHeight / 2 + 1px); | ||
border-top-left-radius: calc($ringHeight / 2); | ||
border-bottom-left-radius: calc($ringHeight / 2); | ||
} | ||
} | ||
|
||
&:hover { | ||
animation-play-state: paused; | ||
} | ||
} | ||
|
||
@keyframes rotate { | ||
0% { | ||
transform: rotate(0deg); | ||
} | ||
100% { | ||
transform: rotate(-360deg); | ||
} | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
src/pages/html/VisualDesign/components/ConicGradientRing/index.tsx
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,59 @@ | ||
import React, { useMemo } from "react"; | ||
import { ECHART_COMMON_COLOR } from "constants/common"; | ||
import styles from "./index.module.scss"; | ||
|
||
const data = [ | ||
{ name: "label1", num: 23 }, | ||
{ name: "label2", num: 12 }, | ||
{ name: "label3", num: 48 }, | ||
{ name: "label4", num: 37 }, | ||
{ name: "label5", num: 18 }, | ||
]; | ||
|
||
const ConicGradientRing = () => { | ||
const dataInfo = useMemo(() => { | ||
const sum = data.reduce((num, next) => num + next.num, 0); | ||
if (data?.length > 0) { | ||
let currentRotate = 0; | ||
const result = data.map((item, index) => { | ||
const rotate = `${currentRotate}deg`; | ||
const degNum = (item.num / sum) * 360; | ||
currentRotate += degNum; | ||
return { | ||
...item, | ||
deg: `${degNum}deg`, | ||
rotate, | ||
color: ECHART_COMMON_COLOR[index], | ||
}; | ||
}); | ||
return result; | ||
} | ||
return []; | ||
}, [data]); | ||
|
||
return ( | ||
<div className={styles.container}> | ||
<div className={styles.box}> | ||
{dataInfo.map((itemData) => { | ||
return ( | ||
<div | ||
className={styles.item} | ||
style={{ | ||
background: `conic-gradient(${itemData.color} 0,transparent ${itemData.deg})`, | ||
transform: `rotate(${itemData.rotate})`, | ||
}} | ||
key={itemData.name} | ||
> | ||
<div | ||
className={styles.semicircle} | ||
style={{ backgroundColor: itemData.color }} | ||
/> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ConicGradientRing; |
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