Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 新增了主题色配置 primaryColor, 现在您可以修改组件中各元素的主色调
- Loading branch information
Showing
10 changed files
with
298 additions
and
268 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
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,120 +1,122 @@ | ||
export const globalStyle = ` | ||
@keyframes oml2d-shake-tips{ | ||
0% { | ||
transform: translate(-50%, 5%) scale(0.99); | ||
} | ||
50% { | ||
transform: translate(-50%, 0%) scale(1); | ||
} | ||
100% { | ||
transform: translate(-50%, 5%) scale(0.99); | ||
} | ||
} | ||
@keyframes oml2d-stage-slide-in { | ||
from { | ||
transform: translateY(130%); | ||
} | ||
to { | ||
transform: translateY(0%); | ||
} | ||
} | ||
@keyframes oml2d-stage-slide-out { | ||
from { | ||
transform: translateY(0%); | ||
} | ||
to { | ||
transform: translateY(130%); | ||
} | ||
} | ||
@keyframes oml2d-display-tips { | ||
0% { | ||
opacity: 0; | ||
visibility: hidden; | ||
} | ||
100% { | ||
opacity: 1; | ||
visibility: visible; | ||
} | ||
} | ||
@keyframes oml2d-hidden-tips { | ||
0% { | ||
opacity: 1; | ||
visibility: visible; | ||
} | ||
100% { | ||
opacity: 0; | ||
visibility: hidden; | ||
} | ||
} | ||
@keyframes oml2d-loading-rotate { | ||
0% { | ||
transform: rotate(0deg); | ||
} | ||
100% { | ||
transform: rotate(360deg); | ||
} | ||
} | ||
.oml2d-icon { | ||
width: 1em; | ||
height: 1em; | ||
vertical-align: -0.15em; | ||
fill: currentColor; | ||
overflow: hidden; | ||
} | ||
.oml2d-loading{ | ||
animation-name: oml2d-loading-rotate; | ||
animation-duration: 600ms; | ||
animation-iteration-count: infinite; | ||
animation-timing-function: linear; | ||
} | ||
.oml2d-menus-item { | ||
width: 36px; | ||
height: 36px; | ||
border-radius: 50%; | ||
display: flex; | ||
justify-content: center; | ||
box-sizing: border-box; | ||
align-items: center; | ||
transition: all 300ms; | ||
color: #58b0fc; | ||
cursor: pointer; | ||
background-color: #fff; | ||
} | ||
.oml2d-menus-item:hover { | ||
background-color: #58b0fc; | ||
color: #fff; | ||
box-shadow: 0 0 5px #000; | ||
} | ||
#oml2dMenus .oml2d-menus-item:not(:last-child) { | ||
margin-bottom: 10px; | ||
} | ||
@keyframes oml2d-status-bar-slide-out { | ||
0% { | ||
transform: translateX(0%); | ||
} | ||
100% { | ||
transform: translateX(-120%); | ||
} | ||
} | ||
@keyframes oml2d-status-bar-slide-in { | ||
0% { | ||
transform: translateX(-120%); | ||
} | ||
100% { | ||
transform: translateX(0%); | ||
} | ||
} | ||
`; | ||
export const generateGlobalStyle = (primaryColor: string): string => { | ||
return ` | ||
@keyframes oml2d-shake-tips{ | ||
0% { | ||
transform: translate(-50%, 5%) scale(0.99); | ||
} | ||
50% { | ||
transform: translate(-50%, 0%) scale(1); | ||
} | ||
100% { | ||
transform: translate(-50%, 5%) scale(0.99); | ||
} | ||
} | ||
@keyframes oml2d-stage-slide-in { | ||
from { | ||
transform: translateY(130%); | ||
} | ||
to { | ||
transform: translateY(0%); | ||
} | ||
} | ||
@keyframes oml2d-stage-slide-out { | ||
from { | ||
transform: translateY(0%); | ||
} | ||
to { | ||
transform: translateY(130%); | ||
} | ||
} | ||
@keyframes oml2d-display-tips { | ||
0% { | ||
opacity: 0; | ||
visibility: hidden; | ||
} | ||
100% { | ||
opacity: 1; | ||
visibility: visible; | ||
} | ||
} | ||
@keyframes oml2d-hidden-tips { | ||
0% { | ||
opacity: 1; | ||
visibility: visible; | ||
} | ||
100% { | ||
opacity: 0; | ||
visibility: hidden; | ||
} | ||
} | ||
@keyframes oml2d-loading-rotate { | ||
0% { | ||
transform: rotate(0deg); | ||
} | ||
100% { | ||
transform: rotate(360deg); | ||
} | ||
} | ||
.oml2d-icon { | ||
width: 1em; | ||
height: 1em; | ||
vertical-align: -0.15em; | ||
fill: currentColor; | ||
overflow: hidden; | ||
} | ||
.oml2d-loading{ | ||
animation-name: oml2d-loading-rotate; | ||
animation-duration: 600ms; | ||
animation-iteration-count: infinite; | ||
animation-timing-function: linear; | ||
} | ||
.oml2d-menus-item { | ||
width: 36px; | ||
height: 36px; | ||
border-radius: 50%; | ||
display: flex; | ||
justify-content: center; | ||
box-sizing: border-box; | ||
align-items: center; | ||
transition: all 300ms; | ||
color: ${primaryColor}; | ||
cursor: pointer; | ||
background-color: #fff; | ||
} | ||
.oml2d-menus-item:hover { | ||
background-color: ${primaryColor}; | ||
color: #fff; | ||
box-shadow: 0 0 5px #000; | ||
} | ||
#oml2dMenus .oml2d-menus-item:not(:last-child) { | ||
margin-bottom: 10px; | ||
} | ||
@keyframes oml2d-status-bar-slide-out { | ||
0% { | ||
transform: translateX(0%); | ||
} | ||
100% { | ||
transform: translateX(-120%); | ||
} | ||
} | ||
@keyframes oml2d-status-bar-slide-in { | ||
0% { | ||
transform: translateX(-120%); | ||
} | ||
100% { | ||
transform: translateX(0%); | ||
} | ||
} | ||
`; | ||
}; |
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,16 @@ | ||
import { generateGlobalStyle } from '../config/style.js'; | ||
import { createElement } from '../utils/index.js'; | ||
|
||
type GlobalStyleType = { primaryColor: string }; | ||
// 全局样式 | ||
export class GlobalStyle { | ||
styleSheet: HTMLElement; | ||
constructor(private style: GlobalStyleType) { | ||
this.styleSheet = createElement({ tagName: 'style', id: 'oml2dStyle', innerHtml: generateGlobalStyle(this.style.primaryColor) }); // 创建全局样式表 | ||
document.head.append(this.styleSheet); | ||
} | ||
|
||
reloadStyleSheet(style: GlobalStyleType): void { | ||
this.styleSheet.innerHTML = generateGlobalStyle(style.primaryColor); | ||
} | ||
} |
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
Oops, something went wrong.