feat(components): add basic components
Some checks failed
Publish package / build_and_publish (push) Failing after 21s
Some checks failed
Publish package / build_and_publish (push) Failing after 21s
This commit is contained in:
parent
ee567abf6b
commit
d4a11146aa
11 changed files with 174 additions and 4 deletions
32
packages/components/build.ts
Normal file
32
packages/components/build.ts
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import { type BunPlugin } from "bun";
|
||||
import dts from "bun-plugin-dts";
|
||||
import styleLoader from "bun-style-loader";
|
||||
import * as sass from "sass";
|
||||
|
||||
const style: BunPlugin = {
|
||||
name: "Sass Loader",
|
||||
setup(build) {
|
||||
console.log("Running SASS Plugin...");
|
||||
build.onLoad({ filter: /\.scss$/ }, async ({ path }) => {
|
||||
const contents = sass.compile(path);
|
||||
const css = contents.css;
|
||||
|
||||
return {
|
||||
loader: "file",
|
||||
contents: css,
|
||||
};
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
const result = await Bun.build({
|
||||
outdir: "dist",
|
||||
publicPath: "public",
|
||||
format: "esm",
|
||||
plugins: [style],
|
||||
entrypoints: ["./src/components.scss"],
|
||||
});
|
||||
|
||||
if (!result.success) {
|
||||
throw new AggregateError(result.logs, "Build failed");
|
||||
}
|
||||
|
|
@ -6,8 +6,19 @@
|
|||
"scripts": {
|
||||
"ci:publish": "bun publish --production --frozen-lockfile"
|
||||
},
|
||||
"exports": {
|
||||
".": "./src/components.scss",
|
||||
"./OffCanvas/": {
|
||||
"import": "./src/OffCanvas/",
|
||||
"require": "./src/OffCanvas/"
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bun": "latest"
|
||||
"@types/bun": "latest",
|
||||
"bun-plugin-dts": "^0.2.3",
|
||||
"bun-style-loader": "^0.4.0",
|
||||
"sass": "^1.79.2",
|
||||
"sass-embedded": "^1.79.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5.0.0"
|
||||
|
|
|
|||
59
packages/components/src/OffCanvas/style.scss
Normal file
59
packages/components/src/OffCanvas/style.scss
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
.off-canvas {
|
||||
.off-canvas-content {
|
||||
overflow: hidden;
|
||||
position: fixed;
|
||||
height: 100vh;
|
||||
z-index: 5;
|
||||
|
||||
background-color: var(--prj-bg);
|
||||
|
||||
top: 0;
|
||||
right: 0;
|
||||
left: 100%;
|
||||
|
||||
padding: var(--prj-spacing-3);
|
||||
|
||||
transition: left 0.4s ease-in-out;
|
||||
}
|
||||
|
||||
&.active .off-canvas-content {
|
||||
left: 50%;
|
||||
}
|
||||
|
||||
.off-canvas-backdrop {
|
||||
position: fixed;
|
||||
height: 100vh;
|
||||
z-index: 4;
|
||||
|
||||
background-color: rgba(0, 0, 0);
|
||||
opacity: 0;
|
||||
|
||||
top: 0;
|
||||
right: 0;
|
||||
left: 100%;
|
||||
|
||||
padding: var(--prj-spacing-3);
|
||||
|
||||
// Delay the left transition on remove so it's desn't appear to be sliding or to be not working
|
||||
transition:
|
||||
opacity 0.8s ease,
|
||||
left 0s linear 1s;
|
||||
}
|
||||
|
||||
&.active .off-canvas-backdrop {
|
||||
left: 0%;
|
||||
opacity: 40%;
|
||||
transition:
|
||||
opacity 0.8s ease,
|
||||
left 0s linear;
|
||||
}
|
||||
}
|
||||
|
||||
button.off-canvas-toggle {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
padding: 0;
|
||||
border: none;
|
||||
background: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
51
packages/components/src/OffCanvas/template.html
Normal file
51
packages/components/src/OffCanvas/template.html
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<div id="mobile-nav" class="off-canvas">
|
||||
<div class="off-canvas-content" transition:persist>
|
||||
<button class="off-canvas-toggle" data-target="#mobile-nav">
|
||||
<svg
|
||||
width="40px"
|
||||
height="40px"
|
||||
viewBox="0 0 1024 1024"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="#ffffff"
|
||||
>
|
||||
<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
|
||||
<g
|
||||
id="SVGRepo_tracerCarrier"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
></g>
|
||||
<g id="SVGRepo_iconCarrier">
|
||||
<path
|
||||
fill="#cad3f5"
|
||||
d="M195.2 195.2a64 64 0 0 1 90.496 0L512 421.504 738.304 195.2a64 64 0 0 1 90.496 90.496L602.496 512 828.8 738.304a64 64 0 0 1-90.496 90.496L512 602.496 285.696 828.8a64 64 0 0 1-90.496-90.496L421.504 512 195.2 285.696a64 64 0 0 1 0-90.496z"
|
||||
></path>
|
||||
</g>
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
<div class="content">
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="off-canvas-backdrop off-canvas-toggle"
|
||||
data-target="#mobile-nav"
|
||||
></div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.addEventListener("astro:page-load", () => {
|
||||
document.querySelectorAll <
|
||||
HTMLElement >
|
||||
".off-canvas-toggle".forEach((btn) =>
|
||||
btn.addEventListener("click", () => {
|
||||
const { target } = btn.dataset;
|
||||
|
||||
if (!target) return;
|
||||
|
||||
document.querySelector(target)?.classList.toggle("active");
|
||||
}),
|
||||
);
|
||||
});
|
||||
</script>
|
||||
|
|
@ -23,5 +23,8 @@
|
|||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": false,
|
||||
"noPropertyAccessFromIndexSignature": false
|
||||
|
||||
// library configuration
|
||||
// "baseUrl": "./src/"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue