Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disable lib check to ensure build succeeds #286

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
],
"sideEffects": false,
"scripts": {
"build": "rimraf dist && tsc && unbuild",
"build": "rimraf dist && pnpm run typecheck && unbuild",
"dev": "unbuild --stub",
"release": "bumpp --commit --push --tag && pnpm publish",
"typecheck": "tsc --noEmit"
Expand All @@ -51,5 +51,6 @@
"unbuild": "^2.0.0",
"unocss": "^0.63.1",
"vite": "^5.0.2"
}
},
"packageManager": "[email protected]+sha512.0a203ffaed5a3f63242cd064c8fb5892366c103e328079318f78062f24ea8c9d50bc6a47aa3567cabefd824d170e78fa2745ed1f16b132e16436146b7688f19b"
}
111 changes: 47 additions & 64 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,78 +1,61 @@
import type { Preset } from 'unocss'
import { definePreset } from 'unocss'
import { colorResolver } from '@unocss/preset-mini/utils';

export function presetScrollbar(): Preset {
return {
name: 'unocss-preset-scrollbar',
variants: [
{
match: (matcher) => {
const matches = matcher.match(
/^(resizer|scrollbar(?:-(?:thumb|track(?:-piece)?|button|corner))?):/
);
if (matches) {
return {
matcher: matcher.slice(matches[0].length),
selector: (s) => `${s}::-webkit-${matches[1]}`
};
}
},
multiPass: true,
}
export const presetScrollbar = definePreset(()=>({
name: 'unocss-preset-scrollbar',
rules: [
[
/^scrollbar-gutter-both$/,
() => ({
'scrollbar-gutter': 'stable both-edges',
})
],
rules: [
[
/^scrollbar-gutter-both$/,
() => ({
'scrollbar-gutter': 'stable both-edges',
})
],
[
/^scrollbar-gutter-(auto|stable|inherit|initial|revert|revert-layer|unset)$/,
([, p]) => ({
'scrollbar-gutter': p,
})
],
[
/^scroll(?:bar)?-(thin|none|auto)$/,
([, w]) => ({
'scrollbar-width': w
})
],
[
/^scroll(?:bar)?-(track|thumb)-(.+)$/,
([s, section, colorMatch], context) => {
const varName = `scroll${section}-bg`;
const opacityVarName = `--un-${varName}-opacity`;
const colorVarName = `--un-${varName}`;
const res = colorResolver('color', varName)([s, colorMatch], context);

if (!res) {
return;
}
[
/^scrollbar-gutter-(auto|stable|inherit|initial|revert|revert-layer|unset)$/,
([, p]) => ({
'scrollbar-gutter': p,
})
],
[
/^scroll(?:bar)?-(thin|none|auto)$/,
([, w]) => ({
'scrollbar-width': w
})
],
[
/^scroll(?:bar)?-(track|thumb)-(.+)$/,
([s, section, colorMatch], context) => {
const varName = `scroll${section}-bg`;
const opacityVarName = `--un-${varName}-opacity`;
const colorVarName = `--un-${varName}`;
const res = colorResolver('color', varName)([s, colorMatch], context);

const color = res['color'];
const opacity = res[opacityVarName];
if (!res) {
return;
}

if (!color) {
return;
}
const color = res['color'];
const opacity = res[opacityVarName];

if (opacity) {
return {
[opacityVarName]: opacity,
[colorVarName]: color,
'scrollbar-color': 'var(--un-scrollthumb-bg) var(--un-scrolltrack-bg)'
};
}
if (!color) {
return;
}

if (opacity) {
return {
[opacityVarName]: opacity,
[colorVarName]: color,
'scrollbar-color': 'var(--un-scrollthumb-bg) var(--un-scrolltrack-bg)'
};
}
]

return {
[colorVarName]: color,
'scrollbar-color': 'var(--un-scrollthumb-bg) var(--un-scrolltrack-bg)'
};
}
]
};
}
]
}))

export default presetScrollbar;
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitAny": false,
"outDir": "./temp",
"declaration": true,
"declarationDir": "./temp",
"emitDeclarationOnly": true,
"skipDefaultLibCheck": true,
"skipLibCheck": true,
"paths": {
"unocss-preset-scrollbar": [
"./src"
Expand Down