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

Update sidebar #23

Merged
merged 1 commit into from
Jun 29, 2023
Merged
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
169 changes: 61 additions & 108 deletions src/assets/scss/components/_sidebar.scss
Original file line number Diff line number Diff line change
@@ -1,89 +1,49 @@
/* @docs */
$sidebar-border-color: $default-border-color !default;
$sidebar-box-shadow: 0 !default;
$sidebar-width: 20% !default;
$sidebar-background-color: $light !default;
$sidebar-overlay-background-color: $overlay-background-color-dark !default;
$sidebar-mobile-width: 5rem !default;
$sidebar-mobile-breakpoint: $tablet !default;
$sidebar-reduced-width: 5rem !default;
$sidebar-reduced-height: 10vh !default;
/* @docs */

.sidebar {

.sidebar-content {
@extend .offcanvas;
visibility: visible;
transition: unset;
background: $light;
width: $sidebar-width;
border-left: 1px solid $sidebar-border-color;
border-right: 1px solid $sidebar-border-color;
box-shadow: $sidebar-box-shadow;
z-index: 999;

// Modifiers
/* @bootstrap docs */
// $offcanvas-padding-y: $modal-inner-padding;
// $offcanvas-padding-x: $modal-inner-padding;
// $offcanvas-horizontal-width: 400px;
// $offcanvas-vertical-height: 30vh;
// $offcanvas-transition-duration: .3s;
// $offcanvas-border-color: $modal-content-border-color;
// $offcanvas-border-width: $modal-content-border-width;
// $offcanvas-title-line-height: $modal-title-line-height;
// $offcanvas-bg-color: var(--#{$prefix}body-bg);
// $offcanvas-color: var(--#{$prefix}body-color);
// $offcanvas-box-shadow: $modal-content-box-shadow-xs;
// $offcanvas-backdrop-bg: $modal-backdrop-bg;
// $offcanvas-backdrop-opacity: $modal-backdrop-opacity;
/* @bootstrap docs */

@mixin size($height, $width) {
&.offcanvas-start,
&.offcanvas-end {
--bs-offcanvas-width: #{$width};
}

&.is-static {
position: static;
}
&.offcanvas-top,
&.offcanvas-bottom {
--bs-offcanvas-height: #{$height};
}
}

&.is-fixed {
position: fixed;
left: 0;
top: 0;
.sidebar {
.offcanvas-backdrop {
@extend .show;
}

&.is-right {
left: auto;
right: 0;
}
}
.offcanvas {
@extend .show;

&.is-absolute {
.btn-close {
border: none !important;
position: absolute;
}

&.is-right {
@extend .offcanvas-end;
transform: unset;
}

&:not(.is-right) {
@extend .offcanvas-start;
transform: unset;
}

&.is-fullheight {
height: 100%;
max-height: 100%;
overflow: hidden;
overflow-y: auto;
display: flex;
flex-direction: column;
align-content: stretch;
}

&.is-fullwidth {
width: 100%;
}

&.is-mini-mobile {
width: 10%;
}

&.is-mini {
width: $sidebar-mobile-width;

&.is-mini-expand:hover:not(.is-mini-delayed) {
transition: width $speed-slow $easing;

&:not(.is-fullwidth) {
width: $sidebar-width;

&.is-mini-expand-fixed {
position: fixed;
}
}
}
right: 0.5rem;
top: 0.5rem;
}

// Colors
Expand All @@ -94,44 +54,37 @@ $sidebar-mobile-breakpoint: $tablet !default;
border: 0;
}
}
@media screen and (max-width: calc($sidebar-mobile-breakpoint - 1px)) {

&.is-mini-mobile {
width: $sidebar-mobile-width;
&.is-fullwidth {
width: 100%;
}

&.is-mini-expand:hover {
&:not(.is-fullheight) {
bottom: unset;
}

&:not(.is-fullwidth-mobile) {
width: $sidebar-width;
// reduced
&.is-reduced {
transition: width $speed-slow $easing, height $speed-slow $easing;

&.is-mini-expand-fixed {
position: fixed;
}
}
@include size($sidebar-reduced-height, $sidebar-reduced-width);

&.is-reduced-expand:hover:not(.is-reduced-delayed) {
&.is-fullwidth {
@include size(100%, 100%h);
}
}

&.is-hidden-mobile {
width: 0;
height: 0;
overflow: hidden;
}
&:not(.is-fullwidth) {
@include size(
$offcanvas-vertical-height,
$offcanvas-horizontal-width
);

&.is-fullwidth-mobile {
width: 100%;
max-width: 100%;
&.is-reduced-expand-fixed {
position: fixed;
}
}
}
}
}

.sidebar-background {
background: $sidebar-overlay-background-color;
@extend .offcanvas-backdrop;
@extend .show;
width: 100%;
height: 100%;
position: fixed;
top: 0;
z-index: 38;
}
}
87 changes: 44 additions & 43 deletions src/components/Sidebar.vue
Original file line number Diff line number Diff line change
@@ -1,64 +1,65 @@
<script setup lang="ts">
import { ref } from "vue";

const isOpen = ref(false);
const isOverlay = ref(true);
const isFullheight = ref(true);
const isFullwidth = ref(false);
const isReduced = ref(false);
const position = ref();
const expandOnHover = ref(false);

const toggleSidebar = () => {
isOpen.value = !isOpen.value;
};
</script>

<template>
<section>
<h2>Sidebar Demoo</h2>
<hr />
</section>

<section class="mt-4">
<o-sidebar
v-model:open="isOpen"
variant="primary"
:fullheight="isFullheight"
:fullwidth="isFullwidth"
:overlay="isOverlay"
:right="isRight"
:position="position"
:reduce="isReduced"
:expand-on-hover="expandOnHover"
mobile="fullwidth"
@close="toggleSidebar()">
<o-button
v-if="isFullwidth"
icon-left="times"
label="Close"
@click="toggleSidebar()" />
<o-button class="btn-close" aria-label="Close" @click="toggleSidebar()" />
<img
width="80"
src="https://avatars2.githubusercontent.com/u/66300512?s=200&v=4"
alt="Lightweight UI components for Vue.js" />
<h3>Example</h3>
</o-sidebar>
<div class="block">
<o-field grouped group-multiline>
<o-switch v-model="isOverlay">Overlay</o-switch>
<o-switch v-model="isFullheight">Fullheight</o-switch>
<o-switch v-model="isFullwidth">Fullwidth</o-switch>
<o-switch v-model="isRight">Right</o-switch>
<o-switch v-model="isReduced">Reduce</o-switch>

<o-field grouped group-multiline>
<o-switch v-model="isOverlay">Overlay</o-switch>
<o-switch v-model="isFullheight">Fullheight</o-switch>
<o-switch v-model="isFullwidth">Fullwidth</o-switch>
<o-switch v-model="isReduced">Reduce</o-switch>
<o-field>
<o-switch v-model="expandOnHover">Expand on hover</o-switch>
</o-field>
</div>

<o-field label="Position">
<o-select v-model="position">
<option value="">default</option>
<option value="top">top</option>
<option value="left">left</option>
<option value="right">right</option>
<option value="bottom">bottom</option>
</o-select>
</o-field>
</o-field>

<o-button @click="toggleSidebar()">Show</o-button>
</section>
</template>

<script lang="ts">
import { ref } from "vue";

export default {
setup() {
const isOpen = ref(false);
const isOverlay = ref(true);
const isFullheight = ref(true);
const isFullwidth = ref(false);
const isRight = ref(false);
const isReduced = ref(false);

const toggleSidebar = () => {
isOpen.value = !isOpen.value;
};

return {
toggleSidebar,
isOpen,
isOverlay,
isFullheight,
isFullwidth,
isRight,
isReduced,
};
},
};
</script>
33 changes: 19 additions & 14 deletions src/plugins/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,23 +462,28 @@ export const bootstrapConfig: any = {
sidebar: {
override: true,
rootClass: "sidebar",
overlayClass: "offcanvas-backdrop",
contentClass: (_: string, { props }: any) => {
const classes = ["offcanvas"];
if (props.position === "left") classes.push("offcanvas-start");
else if (props.position === "right") classes.push("offcanvas-end");
else if (props.position === "top") classes.push("offcanvas-top");
else if (props.position === "bottom") classes.push("offcanvas-bottom");
else if (props.right) classes.push("offcanvas-end");
else classes.push("offcanvas-start");
return classes.join(" ");
},
variantClass: "is-",
contentClass: "sidebar-content",
staticClass: "is-static",
absoluteClass: "is-absolute",
fixedClass: "is-fixed",
expandOnHoverClass: "is-mini-expand",
expandOnHoverFixedClass: "is-mini-expand",
staticClass: "position-static",
absoluteClass: "position-absolute",
fixedClass: "position-fixed",
rightClass: "is-right",
reduceClass: "is-reduced",
expandOnHoverClass: "is-reduced-expand",
expandOnHoverFixedClass: "is-reduced-expand-fixed",
fullheightClass: "is-fullheight",
fullwidthClass: "is-fullwidth",
mobileClass: (_: string, { props }: any) => {
if (props.mobile && props.mobile !== "reduce") {
return `is-${props.mobile}-mobile`;
}
},
overlayClass: "sidebar-background",
reduceClass: "is-mini-mobile",
rightClass: "is-right",
mobileClass: "is-",
},
loading: {
override: true,
Expand Down