Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
design-system-lib
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
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
julkiset-sivut
design-system-lib
Commits
02593fdd
Commit
02593fdd
authored
4 years ago
by
Tuukka Turu
Browse files
Options
Downloads
Patches
Plain Diff
Minor style fixes to tabs and improved scroll behaviour
parent
76ceea4e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/hy-tabs/hy-tabs.scss
+7
-5
7 additions, 5 deletions
src/components/hy-tabs/hy-tabs.scss
src/components/hy-tabs/hy-tabs.tsx
+19
-4
19 additions, 4 deletions
src/components/hy-tabs/hy-tabs.tsx
with
26 additions
and
9 deletions
src/components/hy-tabs/hy-tabs.scss
+
7
−
5
View file @
02593fdd
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
position
:
absolute
;
position
:
absolute
;
top
:
50%
;
top
:
50%
;
transform
:
translateY
(
-50%
);
transform
:
translateY
(
-50%
);
z-index
:
3
;
z-index
:
4
;
&
.is-hidden
{
&
.is-hidden
{
display
:
none
;
display
:
none
;
...
@@ -58,7 +58,7 @@
...
@@ -58,7 +58,7 @@
}
}
&
__left
{
&
__left
{
left
:
0
;
left
:
8px
;
svg
{
svg
{
left
:
-1
.5px
;
left
:
-1
.5px
;
...
@@ -66,7 +66,7 @@
...
@@ -66,7 +66,7 @@
}
}
&
__right
{
&
__right
{
right
:
0
;
right
:
8px
;
svg
{
svg
{
left
:
1
.5px
;
left
:
1
.5px
;
...
@@ -138,11 +138,12 @@
...
@@ -138,11 +138,12 @@
background
:
var
(
--
grayscale-white
);
background
:
var
(
--
grayscale-white
);
border
:
1px
solid
var
(
--
grayscale-tabs-border
);
border
:
1px
solid
var
(
--
grayscale-tabs-border
);
border-bottom-width
:
0
;
border-bottom-width
:
0
;
box-shadow
:
inset
0
1px
0
0
var
(
--
grayscale-medium
)
,
inset
-
1px
1px
0
0
var
(
--
grayscale-medium
)
,
box-shadow
:
inset
0
1px
0
0
#d2d2d2
,
inset
-1px
1px
0
0
#d2d2d2
,
inset
1px
1px
0
0
#d2d2d2
,
inset
1px
1px
0
0
var
(
--
grayscale-medium
)
,
0
-4px
8px
-4px
rgba
(
0
,
0
,
0
,
0
.1
);
0
-4px
8px
-4px
rgba
(
0
,
0
,
0
,
0
.1
);
font-weight
:
bold
;
font-weight
:
bold
;
margin-bottom
:
-1px
;
margin-bottom
:
-1px
;
padding-bottom
:
9px
;
padding-bottom
:
9px
;
z-index
:
3
;
}
}
[
role
=
'tab'
]
:hover
,
[
role
=
'tab'
]
:hover
,
...
@@ -159,6 +160,7 @@
...
@@ -159,6 +160,7 @@
}
}
[
role
=
'tabpanel'
]
{
[
role
=
'tabpanel'
]
{
border-top
:
1px
solid
var
(
--
grayscale-medium
);
padding
:
1
.5em
0
.5em
0
.7em
;
padding
:
1
.5em
0
.5em
0
.7em
;
position
:
relative
;
position
:
relative
;
z-index
:
2
;
z-index
:
2
;
...
...
This diff is collapsed.
Click to expand it.
src/components/hy-tabs/hy-tabs.tsx
+
19
−
4
View file @
02593fdd
...
@@ -19,6 +19,7 @@ let direction = {
...
@@ -19,6 +19,7 @@ let direction = {
};
};
let
checkTimeout
;
let
checkTimeout
;
let
focusTimeout
;
let
focusTimeout
;
let
scrollTimeout
;
@
Component
({
@
Component
({
tag
:
'
hy-tabs
'
,
tag
:
'
hy-tabs
'
,
...
@@ -55,8 +56,20 @@ export class HyTabs implements ComponentInterface {
...
@@ -55,8 +56,20 @@ export class HyTabs implements ComponentInterface {
const
leftButton
=
this
.
el
.
querySelectorAll
(
'
.hy-tab-scroll__left
'
)[
0
];
const
leftButton
=
this
.
el
.
querySelectorAll
(
'
.hy-tab-scroll__left
'
)[
0
];
const
rightButton
=
this
.
el
.
querySelectorAll
(
'
.hy-tab-scroll__right
'
)[
0
];
const
rightButton
=
this
.
el
.
querySelectorAll
(
'
.hy-tab-scroll__right
'
)[
0
];
const
tabList
=
this
.
tabList
as
any
;
const
tabList
=
this
.
tabList
as
any
;
this
.
checkScrollHidden
(
tabList
,
leftButton
,
rightButton
);
this
.
checkScrollHidden
(
tabList
,
leftButton
,
rightButton
);
tabList
.
addEventListener
(
'
scroll
'
,
()
=>
{
scrollTimeout
=
setTimeout
(()
=>
{
window
.
clearTimeout
(
scrollTimeout
);
this
.
checkScrollHidden
(
tabList
,
leftButton
,
rightButton
);
},
250
);
},
false
);
if
(
tabList
.
offSetWidth
<=
document
.
body
.
scrollWidth
)
{
if
(
tabList
.
offSetWidth
<=
document
.
body
.
scrollWidth
)
{
leftButton
.
classList
.
add
(
'
is-hidden
'
);
leftButton
.
classList
.
add
(
'
is-hidden
'
);
rightButton
.
classList
.
add
(
'
is-hidden
'
);
rightButton
.
classList
.
add
(
'
is-hidden
'
);
...
@@ -72,6 +85,7 @@ export class HyTabs implements ComponentInterface {
...
@@ -72,6 +85,7 @@ export class HyTabs implements ComponentInterface {
behavior
:
'
smooth
'
,
behavior
:
'
smooth
'
,
});
});
checkTimeout
=
window
.
setTimeout
(()
=>
{
checkTimeout
=
window
.
setTimeout
(()
=>
{
window
.
clearTimeout
(
checkTimeout
);
this
.
checkScrollHidden
(
tabList
,
leftButton
,
rightButton
);
this
.
checkScrollHidden
(
tabList
,
leftButton
,
rightButton
);
rightButton
.
classList
.
remove
(
'
is-disabled
'
);
rightButton
.
classList
.
remove
(
'
is-disabled
'
);
},
250
);
},
250
);
...
@@ -86,6 +100,7 @@ export class HyTabs implements ComponentInterface {
...
@@ -86,6 +100,7 @@ export class HyTabs implements ComponentInterface {
behavior
:
'
smooth
'
,
behavior
:
'
smooth
'
,
});
});
checkTimeout
=
window
.
setTimeout
(()
=>
{
checkTimeout
=
window
.
setTimeout
(()
=>
{
window
.
clearTimeout
(
checkTimeout
);
this
.
checkScrollHidden
(
tabList
,
leftButton
,
rightButton
);
this
.
checkScrollHidden
(
tabList
,
leftButton
,
rightButton
);
leftButton
.
classList
.
remove
(
'
is-disabled
'
);
leftButton
.
classList
.
remove
(
'
is-disabled
'
);
},
250
);
},
250
);
...
@@ -126,7 +141,6 @@ export class HyTabs implements ComponentInterface {
...
@@ -126,7 +141,6 @@ export class HyTabs implements ComponentInterface {
}
else
{
}
else
{
rightButton
.
classList
.
remove
(
'
is-hidden
'
);
rightButton
.
classList
.
remove
(
'
is-hidden
'
);
}
}
window
.
clearTimeout
(
checkTimeout
);
}
}
// When a tab is clicked, activateTab is fired to activate it
// When a tab is clicked, activateTab is fired to activate it
...
@@ -182,6 +196,7 @@ export class HyTabs implements ComponentInterface {
...
@@ -182,6 +196,7 @@ export class HyTabs implements ComponentInterface {
switch
(
key
)
{
switch
(
key
)
{
case
keys
.
left
:
case
keys
.
left
:
case
keys
.
right
:
case
keys
.
right
:
event
.
preventDefault
();
if
(
this
.
focusTimeoutCleared
)
{
if
(
this
.
focusTimeoutCleared
)
{
this
.
determineOrientation
(
event
);
this
.
determineOrientation
(
event
);
}
}
...
@@ -259,8 +274,6 @@ export class HyTabs implements ComponentInterface {
...
@@ -259,8 +274,6 @@ export class HyTabs implements ComponentInterface {
if
(
setFocus
)
{
if
(
setFocus
)
{
tab
.
focus
();
tab
.
focus
();
}
}
window
.
clearTimeout
(
focusTimeout
);
this
.
focusTimeoutCleared
=
true
;
}
}
// Deactivate all tabs and tab panels
// Deactivate all tabs and tab panels
...
@@ -281,11 +294,13 @@ export class HyTabs implements ComponentInterface {
...
@@ -281,11 +294,13 @@ export class HyTabs implements ComponentInterface {
const
target
=
tab
;
const
target
=
tab
;
this
.
focusTimeoutCleared
=
false
;
this
.
focusTimeoutCleared
=
false
;
focusTimeout
=
window
.
setTimeout
(()
=>
{
focusTimeout
=
window
.
setTimeout
(()
=>
{
window
.
clearTimeout
(
focusTimeout
);
this
.
focusTimeoutCleared
=
true
;
const
focused
=
document
.
activeElement
;
const
focused
=
document
.
activeElement
;
if
(
target
===
focused
)
{
if
(
target
===
focused
)
{
this
.
activateTab
(
target
,
false
);
this
.
activateTab
(
target
,
false
);
}
}
},
30
0
);
},
25
0
);
}
}
render
()
{
render
()
{
...
...
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