Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dima Krasner
Sharkey
Commits
a0c9fd75
Commit
a0c9fd75
authored
3 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
fix ui
parent
94bf7101
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/client/components/global/header.vue
+80
-66
80 additions, 66 deletions
src/client/components/global/header.vue
with
80 additions
and
66 deletions
src/client/components/global/header.vue
+
80
−
66
View file @
a0c9fd75
<
template
>
<div
class=
"fdidabkb"
:class=
"
{ slim: narrow, thin }" :style="{ background: bg }" @click="onClick">
<div
class=
"fdidabkb"
:class=
"
{ slim: narrow, thin }" :style="{ background: bg }" @click="onClick"
ref="el"
>
<template
v-if=
"info"
>
<div
class=
"titleContainer"
@
click=
"showTabsPopup"
>
<i
v-if=
"info.icon"
class=
"icon"
:class=
"info.icon"
></i>
...
...
@@ -37,12 +37,13 @@
</template>
<
script
lang=
"ts"
>
import
{
defineComponent
}
from
'
vue
'
;
import
{
computed
,
defineComponent
,
onMounted
,
PropType
,
ref
}
from
'
vue
'
;
import
*
as
tinycolor
from
'
tinycolor2
'
;
import
{
popupMenu
}
from
'
@client/os
'
;
import
{
url
}
from
'
@client/config
'
;
import
{
scrollToTop
}
from
'
@client/scripts/scroll
'
;
import
MkButton
from
'
@client/components/ui/button.vue
'
;
import
{
i18n
}
from
'
../../i18n
'
;
export
default
defineComponent
({
components
:
{
...
...
@@ -51,6 +52,10 @@ export default defineComponent({
props
:
{
info
:
{
type
:
Object
as
PropType
<
{
actions
?:
{}[];
tabs
?:
{}[];
}
>
,
required
:
true
},
menu
:
{
...
...
@@ -62,99 +67,108 @@ export default defineComponent({
},
},
data
()
{
return
{
bg
:
null
,
narrow
:
false
,
height
:
0
,
};
},
computed
:
{
hasTabs
():
boolean
{
return
this
.
info
.
tabs
&&
this
.
info
.
tabs
.
length
>
0
;
},
shouldShowMenu
()
{
if
(
this
.
info
==
null
)
return
false
;
if
(
this
.
info
.
actions
!=
null
&&
this
.
narrow
)
return
true
;
if
(
this
.
info
.
menu
!=
null
)
return
true
;
if
(
this
.
info
.
share
!=
null
)
return
true
;
if
(
this
.
menu
!=
null
)
return
true
;
setup
(
props
)
{
const
el
=
ref
<
HTMLElement
>
(
null
);
const
bg
=
ref
(
null
);
const
narrow
=
ref
(
false
);
const
height
=
ref
(
0
);
const
hasTabs
=
computed
(()
=>
{
return
props
.
info
.
tabs
&&
props
.
info
.
tabs
.
length
>
0
;
});
const
shouldShowMenu
=
computed
(()
=>
{
if
(
props
.
info
==
null
)
return
false
;
if
(
props
.
info
.
actions
!=
null
&&
narrow
.
value
)
return
true
;
if
(
props
.
info
.
menu
!=
null
)
return
true
;
if
(
props
.
info
.
share
!=
null
)
return
true
;
if
(
props
.
menu
!=
null
)
return
true
;
return
false
;
}
},
mounted
()
{
const
rawBg
=
this
.
info
?.
bg
||
'
var(--bg)
'
;
const
bg
=
tinycolor
(
rawBg
.
startsWith
(
'
var(
'
)
?
getComputedStyle
(
document
.
documentElement
).
getPropertyValue
(
rawBg
.
slice
(
4
,
-
1
))
:
rawBg
);
bg
.
setAlpha
(
0.85
);
this
.
bg
=
bg
.
toRgbString
();
if
(
this
.
$el
.
parentElement
)
{
this
.
narrow
=
this
.
$el
.
parentElement
.
offsetWidth
<
500
;
new
ResizeObserver
((
entries
,
observer
)
=>
{
this
.
narrow
=
this
.
$el
.
parentElement
.
offsetWidth
<
500
;
}).
observe
(
this
.
$el
.
parentElement
);
const
currentStickyTop
=
getComputedStyle
(
this
.
$el
).
getPropertyValue
(
'
--stickyTop
'
)
||
'
0px
'
;
this
.
$el
.
style
.
setProperty
(
'
--stickyTop
'
,
currentStickyTop
);
this
.
$el
.
parentElement
.
style
.
setProperty
(
'
--stickyTop
'
,
`calc(
${
currentStickyTop
}
+
${
this
.
$el
.
offsetHeight
}
px)`
);
}
},
});
methods
:
{
share
()
{
const
share
=
()
=>
{
navigator
.
share
({
url
:
url
+
thi
s
.
info
.
path
,
...
thi
s
.
info
.
share
,
url
:
url
+
prop
s
.
info
.
path
,
...
prop
s
.
info
.
share
,
});
}
,
}
;
showMenu
(
ev
)
{
let
menu
=
thi
s
.
info
.
menu
?
thi
s
.
info
.
menu
()
:
[];
if
(
this
.
narrow
&&
thi
s
.
info
.
actions
)
{
menu
=
[...
thi
s
.
info
.
actions
.
map
(
x
=>
({
const
showMenu
=
(
ev
:
MouseEvent
)
=>
{
let
menu
=
prop
s
.
info
.
menu
?
prop
s
.
info
.
menu
()
:
[];
if
(
narrow
.
value
&&
prop
s
.
info
.
actions
)
{
menu
=
[...
prop
s
.
info
.
actions
.
map
(
x
=>
({
text
:
x
.
text
,
icon
:
x
.
icon
,
action
:
x
.
handler
})),
menu
.
length
>
0
?
null
:
undefined
,
...
menu
];
}
if
(
thi
s
.
info
.
share
)
{
if
(
prop
s
.
info
.
share
)
{
if
(
menu
.
length
>
0
)
menu
.
push
(
null
);
menu
.
push
({
text
:
this
.
$ts
.
share
,
text
:
i18n
.
locale
.
share
,
icon
:
'
fas fa-share-alt
'
,
action
:
this
.
share
action
:
share
});
}
if
(
thi
s
.
menu
)
{
if
(
prop
s
.
menu
)
{
if
(
menu
.
length
>
0
)
menu
.
push
(
null
);
menu
=
menu
.
concat
(
thi
s
.
menu
);
menu
=
menu
.
concat
(
prop
s
.
menu
);
}
popupMenu
(
menu
,
ev
.
currentTarget
||
ev
.
target
);
}
,
}
;
showTabsPopup
(
ev
)
{
if
(
!
this
.
hasTabs
)
return
;
if
(
!
this
.
narrow
)
return
;
const
showTabsPopup
=
(
ev
:
MouseEvent
)
=>
{
if
(
!
hasTabs
.
value
)
return
;
if
(
!
narrow
.
value
)
return
;
ev
.
preventDefault
();
ev
.
stopPropagation
();
const
menu
=
thi
s
.
info
.
tabs
.
map
(
tab
=>
({
const
menu
=
prop
s
.
info
.
tabs
.
map
(
tab
=>
({
text
:
tab
.
title
,
icon
:
tab
.
icon
,
action
:
tab
.
onClick
,
}));
popupMenu
(
menu
,
ev
.
currentTarget
||
ev
.
target
);
}
,
}
;
preventDrag
(
ev
)
{
const
preventDrag
=
(
ev
:
TouchEvent
)
=>
{
ev
.
stopPropagation
();
}
,
}
;
onClick
(
ev
)
{
scrollToTop
(
this
.
$el
,
{
behavior
:
'
smooth
'
});
}
}
const
onClick
=
()
=>
{
scrollToTop
(
el
.
value
,
{
behavior
:
'
smooth
'
});
};
onMounted
(()
=>
{
const
rawBg
=
props
.
info
?.
bg
||
'
var(--bg)
'
;
const
tinyBg
=
tinycolor
(
rawBg
.
startsWith
(
'
var(
'
)
?
getComputedStyle
(
document
.
documentElement
).
getPropertyValue
(
rawBg
.
slice
(
4
,
-
1
))
:
rawBg
);
tinyBg
.
setAlpha
(
0.85
);
bg
.
value
=
tinyBg
.
toRgbString
();
if
(
el
.
value
.
parentElement
)
{
narrow
.
value
=
el
.
value
.
parentElement
.
offsetWidth
<
500
;
new
ResizeObserver
((
entries
,
observer
)
=>
{
narrow
.
value
=
el
.
value
.
parentElement
.
offsetWidth
<
500
;
}).
observe
(
el
.
value
.
parentElement
);
setTimeout
(()
=>
{
const
currentStickyTop
=
getComputedStyle
(
el
.
value
.
parentElement
).
getPropertyValue
(
'
--stickyTop
'
)
||
'
0px
'
;
el
.
value
.
style
.
setProperty
(
'
--stickyTop
'
,
currentStickyTop
);
el
.
value
.
parentElement
.
style
.
setProperty
(
'
--stickyTop
'
,
`calc(
${
currentStickyTop
}
+
${
el
.
value
.
offsetHeight
}
px)`
);
},
100
);
// レンダリング順序の関係で親のstickyTopの設定が少し遅れることがあるため
}
});
return
{
el
,
bg
,
narrow
,
height
,
hasTabs
,
shouldShowMenu
,
share
,
showMenu
,
showTabsPopup
,
preventDrag
,
onClick
,
};
},
});
</
script
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment