init
This commit is contained in:
62
uni_modules/nutui-uni/components/subsidenavbar/index.scss
Normal file
62
uni_modules/nutui-uni/components/subsidenavbar/index.scss
Normal file
@@ -0,0 +1,62 @@
|
||||
.nut-theme-dark {
|
||||
.nut-sub-side-navbar {
|
||||
background-color: $dark-background2;
|
||||
|
||||
&__title {
|
||||
color: $dark-color;
|
||||
background-color: $dark-background3;
|
||||
|
||||
&__text {
|
||||
color: $dark-color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.nut-sub-side-navbar {
|
||||
position: relative;
|
||||
display: grid;
|
||||
float: left;
|
||||
width: 100%;
|
||||
|
||||
&__title {
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
display: block;
|
||||
width: $sidenavbar-sub-title-width;
|
||||
height: $sidenavbar-sub-title-height;
|
||||
overflow: hidden;
|
||||
font-size: $sidenavbar-sub-title-font-size;
|
||||
color: $sidenavbar-sub-title-text-color;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
background-color: $sidenavbar-sub-title-bg-color;
|
||||
border: $sidenavbar-sub-title-border;
|
||||
border-bottom: 1px solid $sidenavbar-sub-title-border-color;
|
||||
border-radius: $sidenavbar-sub-title-radius;
|
||||
|
||||
&__text {
|
||||
line-height: $sidenavbar-sub-title-text-line-height;
|
||||
color: $sidenavbar-sub-title-text-color;
|
||||
}
|
||||
|
||||
&__icon {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
right: 20px;
|
||||
transform: translateY(-50%);
|
||||
|
||||
.icon {
|
||||
transition: transform 0.5s ease-in-out;
|
||||
|
||||
&.up {
|
||||
transform: rotate(-180deg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&__list {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
1
uni_modules/nutui-uni/components/subsidenavbar/index.ts
Normal file
1
uni_modules/nutui-uni/components/subsidenavbar/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './subsidenavbar'
|
||||
@@ -0,0 +1,26 @@
|
||||
import type { ExtractPropTypes } from 'vue'
|
||||
import { commonProps, truthProp } from '../_utils'
|
||||
|
||||
export const subsidenavbarProps = {
|
||||
...commonProps,
|
||||
/**
|
||||
* @description 导航标题
|
||||
*/
|
||||
title: String,
|
||||
/**
|
||||
* @description 导航唯一标识
|
||||
*/
|
||||
ikey: [String, Number],
|
||||
/**
|
||||
* @description 导航是否默认展开
|
||||
*/
|
||||
open: truthProp,
|
||||
}
|
||||
|
||||
export type SubSidenavbarProps = ExtractPropTypes<typeof subsidenavbarProps>
|
||||
|
||||
export const subsidenavbarEmits = {
|
||||
titleClick: () => true,
|
||||
}
|
||||
|
||||
export type SubSidenavbarEmits = typeof subsidenavbarEmits
|
||||
@@ -0,0 +1,80 @@
|
||||
<script setup lang="ts">
|
||||
import type { CSSProperties } from 'vue'
|
||||
import { computed, defineComponent, onMounted, ref } from 'vue'
|
||||
import { PREFIX } from '../_constants'
|
||||
import { useInject } from '../_hooks'
|
||||
import { getMainClass } from '../_utils'
|
||||
import NutIcon from '../icon/icon.vue'
|
||||
import type { SidenavbarProps } from '../sidenavbar'
|
||||
import { SIDEN_NAVBAR_KEY } from '../sidenavbar'
|
||||
import { subsidenavbarEmits, subsidenavbarProps } from './subsidenavbar'
|
||||
|
||||
const props = defineProps(subsidenavbarProps)
|
||||
const emit = defineEmits(subsidenavbarEmits)
|
||||
const direction = ref('')
|
||||
const classes = computed(() => {
|
||||
return getMainClass(props, componentName)
|
||||
})
|
||||
const Parent = useInject<{ props: Required<SidenavbarProps> }>(SIDEN_NAVBAR_KEY)
|
||||
|
||||
const paddingStyle = computed(() => {
|
||||
return {
|
||||
paddingLeft: `${Number(Parent.parent?.props?.offset)}px`,
|
||||
} as CSSProperties
|
||||
})
|
||||
const style = computed(() => {
|
||||
return {
|
||||
height: !direction.value ? 'auto' : '0px',
|
||||
}
|
||||
})
|
||||
function handleClick() {
|
||||
emit('titleClick')
|
||||
direction.value = !direction.value ? 'up' : ''
|
||||
}
|
||||
onMounted(() => {
|
||||
direction.value = props.open ? '' : 'up'
|
||||
})
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
const componentName = `${PREFIX}-sub-side-navbar`
|
||||
|
||||
export default defineComponent({
|
||||
name: componentName,
|
||||
options: {
|
||||
virtualHost: true,
|
||||
addGlobalClass: true,
|
||||
styleIsolation: 'shared',
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view :class="classes" :style="customStyle" :ikey="ikey">
|
||||
<view class="nut-sub-side-navbar__title" :style="[paddingStyle]" @click.stop="handleClick">
|
||||
<text class="nut-sub-side-navbar__title__text">
|
||||
{{ title }}
|
||||
</text>
|
||||
<view class="nut-sub-side-navbar__title__icon">
|
||||
<NutIcon
|
||||
v-if="!direction"
|
||||
custom-class="icon"
|
||||
name="arrow-down2"
|
||||
size="12px"
|
||||
/>
|
||||
<NutIcon v-else name="arrow-up2" size="12px" />
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
class="nut-sub-side-navbar__list"
|
||||
:class="[{ 'nut-hidden': direction }, direction ? 'nutFadeOut' : 'nutFadeIn']"
|
||||
:style="[style]"
|
||||
>
|
||||
<slot />
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style lang="scss">
|
||||
@import './index';
|
||||
</style>
|
||||
Reference in New Issue
Block a user