Skip to content

Commit

Permalink
Refactoring teleports & off-canvas (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
akadlec authored Mar 6, 2022
1 parent a0952df commit 5058300
Show file tree
Hide file tree
Showing 16 changed files with 114 additions and 208 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fastybird/web-ui-theme",
"version": "0.6.7",
"version": "0.7.0",
"description": "FastyBird basic theme & Vue components for web apps",
"keywords": [
"fastybird",
Expand Down
1 change: 0 additions & 1 deletion src/assets/components/layout/fb-header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ $header-font-weight: normal;
$hamburger-bar-line-height: 2px !default;
$hamburger-bar-line-width: 22px !default;
$hamburger-bar-line-distance: 5px !default;
$screen-tablet-min: $screen-sm-min;

@mixin shadow {
@include box-shadow(0 3px 9px rgba(0, 0, 0, 0.5));
Expand Down
12 changes: 0 additions & 12 deletions src/assets/components/layout/fb-off-canvas.scss
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
@import "../../variables/colors";
@import "../../variables/layout";
@import "../../variables/screen";
@import "../../variables/texts";
@import "../../mixins/utilities";

$off-canvas-header-height: 5rem;
$off-canvas-header-padding: 0 $padding-md;
$off-canvas-header-color: $color-primary-contrast;
$off-canvas-header-bg-color: $color-primary;
$off-canvas-header-font-size: $font-size-h4;
$off-canvas-header-font-weight: $headings-font-weight;
$off-canvas-header-line-height: $headings-line-height;
$off-canvas-header-color: $color-primary-contrast;
$off-canvas-button-color: $color-primary-contrast;
$off-canvas-button-font-size: 2.5rem;
$off-canvas-button-line-height: 5rem;
$off-canvas-overlay-color: rgb(0 0 0 / 50%);
$off-canvas-overlay-zindex: $zindex-off-canvas-background;
$off-canvas-body-color: $bg-color-body;
Expand Down
59 changes: 54 additions & 5 deletions src/components/layout/FbHeader/Button/index.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,57 @@
<template>
<teleport
:to="`#${teleportTarget}`"
:disabled="!teleport"
>
<template v-if="teleport">
<teleport :to="`#${teleportTarget}`">
<template v-if="actionType === menuItemTypes.LINK">
<a
:href="action"
:class="['fb-theme-layout-header-button__container', {'fb-theme-layout-header-button__container-small': small}, {'fb-theme-layout-header-button__container-textual': !('icon' in $slots)}, {'fb-theme-layout-header-button__container-left': left}, {'fb-theme-layout-header-button__container-right': right}]"
@click.prevent="$emit('click', $event)"
>
<template v-if="'icon' in $slots">
<slot name="icon" />
</template>

<template v-else>
{{ label }}
</template>
</a>
</template>

<template v-else-if="actionType === menuItemTypes.VUE_LINK">
<router-link
:to="action"
:class="['fb-theme-layout-header-button__container', {'fb-theme-layout-header-button__container-small': small}, {'fb-theme-layout-header-button__container-textual': !('icon' in $slots)}, {'fb-theme-layout-header-button__container-left': left}, {'fb-theme-layout-header-button__container-right': right}]"
@click.prevent="$emit('click', $event)"
>
<template v-if="'icon' in $slots">
<slot name="icon" />
</template>

<template v-else>
{{ label }}
</template>
</router-link>
</template>

<template v-else-if="actionType === menuItemTypes.BUTTON">
<button
role="button"
:class="['fb-theme-layout-header-button__container', {'fb-theme-layout-header-button__container-small': small}, {'fb-theme-layout-header-button__container-textual': !('icon' in $slots)}, {'fb-theme-layout-header-button__container-left': left}, {'fb-theme-layout-header-button__container-right': right}]"
@click.prevent="$emit('click', $event)"
>
<template v-if="'icon' in $slots">
<slot name="icon" />
</template>

<template v-else>
{{ label }}
</template>
</button>
</template>
</teleport>
</template>

<template v-else>
<template v-if="actionType === menuItemTypes.LINK">
<a
:href="action"
Expand Down Expand Up @@ -50,7 +99,7 @@
</template>
</button>
</template>
</teleport>
</template>
</template>

<script lang="ts">
Expand Down
4 changes: 2 additions & 2 deletions src/components/layout/FbHeader/Button/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { FbMenuItemTypes } from "@/types";

export interface IFbLayoutHeaderButtonProps {
type: FbMenuItemTypes;
actionType: FbMenuItemTypes;
action: string | { [key: string]: any } | null;
label: string | null;
link: string | null;
small: boolean;
left: boolean;
right: boolean;
Expand Down
15 changes: 10 additions & 5 deletions src/components/layout/FbHeader/Content/index.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<template>
<teleport
to="#fb-layout-header-sub-content"
:disabled="!teleport"
>
<template v-if="teleport">
<teleport to="#fb-layout-header-sub-content">
<div class="fb-theme-layout-phone-header-content__container">
<slot />
</div>
</teleport>
</template>

<template v-else>
<div class="fb-theme-layout-phone-header-content__container">
<slot />
</div>
</teleport>
</template>
</template>

<script lang="ts">
Expand Down
31 changes: 26 additions & 5 deletions src/components/layout/FbHeader/Heading/index.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
<template>
<teleport
to="#fb-layout-header-heading"
:disabled="!teleport"
>
<template v-if="teleport">
<teleport to="#fb-layout-header-heading">
<div class="fb-theme-layout-phone-header-heading__container">
<div :class="['fb-theme-layout-phone-header-heading__heading', `fb-theme-layout-phone-header-heading__heading-${align}`]">
<h1 v-if="subHeading === null">
{{ heading }}
</h1>

<h1 v-if="subHeading !== null">
<span>{{ heading }}</span>
<small>{{ subHeading }}</small>
</h1>
</div>

<div
v-if="'icon' in $slots"
class="fb-theme-layout-phone-header-heading__icon"
>
<slot name="icon" />
</div>
</div>
</teleport>
</template>

<template v-else>
<div class="fb-theme-layout-phone-header-heading__container">
<div :class="['fb-theme-layout-phone-header-heading__heading', `fb-theme-layout-phone-header-heading__heading-${align}`]">
<h1 v-if="subHeading === null">
Expand All @@ -22,7 +43,7 @@
<slot name="icon" />
</div>
</div>
</teleport>
</template>
</template>

<script lang="ts">
Expand Down
17 changes: 12 additions & 5 deletions src/components/layout/FbHeader/Icon/index.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
<template>
<teleport
:to="`#${teleportTarget}`"
:disabled="!teleport"
>
<template v-if="teleport">
<teleport :to="`#${teleportTarget}`">
<div
:class="['fb-theme-layout-header-icon__container', {'fb-theme-layout-header-icon__container-left': left}, {'fb-theme-layout-header-icon__container-right': right}]"
>
<slot />
</div>
</teleport>
</template>

<template v-else>
<div
:class="['fb-theme-layout-header-icon__container', {'fb-theme-layout-header-icon__container-left': left}, {'fb-theme-layout-header-icon__container-right': right}]"
>
<slot />
</div>
</teleport>
</template>
</template>

<script lang="ts">
Expand Down
13 changes: 8 additions & 5 deletions src/components/layout/FbHeader/Spacer/index.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<template>
<teleport
:to="`#${teleportTarget}`"
:disabled="!teleport"
>
<template v-if="teleport">
<teleport :to="`#${teleportTarget}`">
<div :class="['fb-theme-layout-header__spacer', {'fb-theme-layout-header__spacer-left': left}, {'fb-theme-layout-header__spacer-right': right}, {'fb-theme-layout-header__spacer-center': !right && !left}]" />
</teleport>
</template>

<template v-else>
<div :class="['fb-theme-layout-header__spacer', {'fb-theme-layout-header__spacer-left': left}, {'fb-theme-layout-header__spacer-right': right}, {'fb-theme-layout-header__spacer-center': !right && !left}]" />
</teleport>
</template>
</template>

<script lang="ts">
Expand Down
4 changes: 0 additions & 4 deletions src/components/layout/FbHeader/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
z-index: $z-index;

@include shadow;

@media (min-width: $screen-tablet-min) {
display: none !important;
}
}

&__heading {
Expand Down
76 changes: 0 additions & 76 deletions src/components/layout/FbOffCanvas/Body/index.scss

This file was deleted.

43 changes: 0 additions & 43 deletions src/components/layout/FbOffCanvas/Body/index.vue

This file was deleted.

16 changes: 0 additions & 16 deletions src/components/layout/FbOffCanvas/Button/index.scss

This file was deleted.

Loading

0 comments on commit 5058300

Please sign in to comment.