Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
components
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tracing
components
Commits
731240ea
Commit
731240ea
authored
Mar 08, 2022
by
chenqikuai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sideBar组件
parent
a38e9067
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
129 additions
and
0 deletions
+129
-0
index.ts
src/components/src/SideBar/index.ts
+8
-0
index.vue
src/components/src/SideBar/index.vue
+73
-0
SideBar.stories.ts
src/stories/SideBar.stories.ts
+44
-0
tailwind.config.js
tailwind.config.js
+4
-0
No files found.
src/components/src/SideBar/index.ts
0 → 100644
View file @
731240ea
import
SideBar
from
"./index.vue"
;
import
{
App
}
from
"vue"
;
SideBar
.
install
=
(
app
:
App
)
=>
{
app
.
component
(
SideBar
.
name
,
SideBar
);
};
export
default
SideBar
;
src/components/src/SideBar/index.vue
0 → 100644
View file @
731240ea
<
template
>
<!-- 左侧导航栏 -->
<nav
class=
"h-full bg-mBlack text-center text-xs flow-root"
style=
"color: rgba(255, 255, 255, 0.6);"
:style=
"
{
width: sideBarWidth + 'px',
}"
>
<div
class=
"h-15 relative cursor-pointer"
style=
"margin-top: 21px;"
v-for=
"(menu, i) in menuList"
:key=
"i"
:class=
"
{
'bg-mGray5 ': currentRoute === i,
'!mt-20': i === 0,
}"
@click="selectPage
&&
selectPage(i)"
>
<div
class=
"box-content"
style=
"padding: 14px 0 5px 0;"
>
<i
class=
"iconfont text-sm"
v-html=
"menu.icon"
></i>
</div>
<div
style=
"line-height: 17px;"
>
{{
menu
.
name
}}
</div>
<div
class=
"hidden absolute top-0 left-0 h-full bg-mBlue"
:class=
"
{
'!block': currentRoute === i,
}"
style="width: 3px;"
>
</div>
</div>
</nav>
</
template
>
<
script
setup
lang=
"ts"
>
import
{
onBeforeMount
}
from
"vue"
;
interface
Props
{
currentRoute
?:
number
;
selectPage
?:
(
i
:
number
)
=>
void
;
menuList
?:
{
name
:
string
;
icon
:
string
;
}[];
iconfontLink
?:
string
;
sideBarWidth
?:
number
;
}
const
props
=
withDefaults
(
defineProps
<
Props
>
(),
{
menuList
:
()
=>
{
return
[];
},
sideBarWidth
:
62
,
});
onBeforeMount
(()
=>
{
if
(
props
.
iconfontLink
)
{
const
links
=
document
.
querySelectorAll
(
"link"
);
let
inserted
=
false
;
for
(
let
i
=
0
;
i
<
links
.
length
;
++
i
)
{
if
(
props
.
iconfontLink
===
links
[
i
].
href
)
{
inserted
=
true
;
}
}
if
(
!
inserted
)
{
const
linkEl
=
document
.
createElement
(
"link"
);
linkEl
.
rel
=
"stylesheet"
;
linkEl
.
href
=
props
.
iconfontLink
;
document
.
head
.
appendChild
(
linkEl
);
}
}
});
</
script
>
src/stories/SideBar.stories.ts
0 → 100644
View file @
731240ea
import
{
Story
}
from
"@storybook/vue3"
;
import
SideBar
from
"../components/src/SideBar"
;
export
default
{
title
:
"SideBar"
,
component
:
SideBar
,
};
const
Template
:
Story
=
(
args
)
=>
({
// Components used in your story `template` are defined in the `components` object
components
:
{
SideBar
},
// The story's `args` need to be mapped into the template through the `setup()` method
setup
()
{
return
{
args
};
},
// And then the `args` are bound to your component with `v-bind="args"`
template
:
'<SideBar v-bind="args" />'
,
});
export
const
Primary
=
Template
.
bind
({});
// More on args: https://storybook.js.org/docs/vue/writing-stories/args
Primary
.
args
=
{
menuList
:
[
{
name
:
"存证"
,
icon
:
""
,
},
{
name
:
"溯源"
,
icon
:
""
,
},
{
name
:
"管理"
,
icon
:
""
,
},
],
currentRoute
:
0
,
iconfontLink
:
"//at.alicdn.com/t/font_1321935_cdom05madx.css"
,
selectPage
(
v
:
number
)
{
console
.
log
(
v
,
"show v"
);
},
sideBarWidth
:
64
,
};
tailwind.config.js
View file @
731240ea
...
...
@@ -5,6 +5,7 @@ module.exports = {
spacing
:
{
pcWidth
:
"1200px"
,
12.5
:
"50px"
,
15
:
"60px"
,
25
:
"100px"
,
26.5
:
"106px"
,
49
:
"196px"
,
...
...
@@ -58,7 +59,10 @@ module.exports = {
mGray2
:
"rgba(74, 74, 74, 1)"
,
mGray3
:
"rgba(162, 157, 202, 1)"
,
mGray4
:
"rgba(53, 53, 53, 1)"
,
mGray5
:
"#39393e"
,
mBlack
:
"#27272a"
,
mLightBlue
:
"rgba(21, 203, 186, 1)"
,
mBlue
:
"#3f79fe"
,
},
fontFamily
:
{
PingFangSC
:
[
"PingFangSC-Regular"
],
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment