2023-04-17 09:23:03 +08:00
|
|
|
import { defineConfig, toEscapedSelector as e, presetUno } from 'unocss'
|
2023-04-17 14:53:09 +08:00
|
|
|
// color: ${JSON.stringify(rules)} ${JSON.stringify(variantHandlers)};
|
|
|
|
|
|
|
|
const POSITION_MAP = {
|
|
|
|
t: 'top',
|
|
|
|
b: 'bottom',
|
|
|
|
l: 'left',
|
|
|
|
r: 'right',
|
|
|
|
top: 'top',
|
|
|
|
bottom: 'bottom',
|
|
|
|
left: 'left',
|
|
|
|
right: 'right'
|
|
|
|
}
|
2023-04-17 09:23:03 +08:00
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
// ...UnoCSS options
|
|
|
|
rules: [
|
|
|
|
[
|
2023-04-17 14:53:09 +08:00
|
|
|
/^custom-b-(.+)-(\d+)$/,
|
|
|
|
([_, position, count], { rawSelector, rules, variantHandlers }) => {
|
|
|
|
// custom-b-bottom-1 或者 custom-b-b-1
|
|
|
|
const selector = e(rawSelector)
|
|
|
|
const newPosition = POSITION_MAP[position]
|
|
|
|
return `
|
|
|
|
${selector}:after {
|
|
|
|
content: '';
|
|
|
|
position: absolute;
|
|
|
|
width: ${newPosition === 'bottom' || newPosition === 'top' ? '100%' : count + 'px'};
|
|
|
|
height: ${newPosition === 'left' || newPosition === 'right' ? '100%' : count + 'px'};
|
|
|
|
${newPosition === 'bottom' ? 'bottom' : 'top'}: 0px;
|
|
|
|
${newPosition === 'right' ? 'right' : 'left'}: 0px;
|
|
|
|
background-color: var(--custom-border-color-light);
|
|
|
|
}
|
|
|
|
|
|
|
|
.dark ${selector}:after {
|
|
|
|
background-color: var(--el-border-color);
|
|
|
|
}
|
|
|
|
`
|
2023-04-17 09:23:03 +08:00
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
2023-04-17 14:53:09 +08:00
|
|
|
/^custom-hover$/,
|
|
|
|
([], { rawSelector }) => {
|
2023-04-17 09:23:03 +08:00
|
|
|
const selector = e(rawSelector)
|
|
|
|
return `
|
|
|
|
${selector} {
|
|
|
|
display: flex;
|
|
|
|
height: 100%;
|
|
|
|
padding: 1px 10px 0;
|
|
|
|
cursor: pointer;
|
|
|
|
align-items: center;
|
|
|
|
transition: background var(--transition-time-02);
|
|
|
|
}
|
|
|
|
/* you can have multiple rules */
|
|
|
|
${selector}:hover {
|
|
|
|
background-color: var(--top-header-hover-color);
|
|
|
|
}
|
2023-04-17 14:53:09 +08:00
|
|
|
.dark ${selector}:hover {
|
2023-04-17 09:23:03 +08:00
|
|
|
background-color: var(--el-bg-color-overlay);
|
|
|
|
}
|
|
|
|
`
|
|
|
|
}
|
|
|
|
]
|
|
|
|
],
|
|
|
|
presets: [presetUno({ dark: 'class', attributify: false })]
|
|
|
|
})
|