Skip to content

Commit c9ad69f

Browse files
authored
Hide h-scrollbar on tabs (#54)
1 parent c9cb598 commit c9ad69f

File tree

3 files changed

+39
-27
lines changed

3 files changed

+39
-27
lines changed

docs/Examples/Tab.example.purs

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,35 @@ docs = flip element {} $ withRouter $ toReactComponent identity component { rend
2626
column_
2727
[ h2_ "Demo 1"
2828
, example $
29-
tabs
30-
{ currentLocation: URL $ "#" <> props.location.pathname <> props.location.search <> props.location.hash
31-
, useHash: true
32-
, navigate: Just \url ->
33-
let
34-
parts = urlParts url
35-
newUrl = parts.path <> parts.query <> parts.hash.path <> parts.hash.query
36-
newUrlNoHash = fromMaybe "" $ flip index 1 $ split (Pattern "#") newUrl
37-
in
38-
runEffectFn1 props.history.push $ URL $ newUrlNoHash
39-
, queryKey: TabKey "demo1"
40-
, style: R.css {}
41-
, tabStyle: R.css {}
42-
, selectedTabStyle: R.css {}
43-
, tabs: 1 .. 6 <#> \i ->
44-
let
45-
label = "Tab with a long title " <> show i
46-
in
47-
{ content: \_ -> empty
48-
, id: TabId (toLower label)
49-
, label
50-
, count: (7*(i - 1) * (i - 1) `mod` 4) * 7 <$ guard (i `mod` 3 /= 1)
51-
, testId: Nothing
52-
}
29+
R.div
30+
{ style: R.css { maxWidth: "800px" }
31+
, children:
32+
[ tabs
33+
{ currentLocation: URL $ "#" <> props.location.pathname <> props.location.search <> props.location.hash
34+
, useHash: true
35+
, navigate: Just \url ->
36+
let
37+
parts = urlParts url
38+
newUrl = parts.path <> parts.query <> parts.hash.path <> parts.hash.query
39+
newUrlNoHash = fromMaybe "" $ flip index 1 $ split (Pattern "#") newUrl
40+
in
41+
runEffectFn1 props.history.push $ URL $ newUrlNoHash
42+
, queryKey: TabKey "demo1"
43+
, style: R.css {}
44+
, tabStyle: R.css {}
45+
, selectedTabStyle: R.css {}
46+
, tabs: 1 .. 10 <#> \i ->
47+
let
48+
label = "Tab with a long title " <> show i
49+
in
50+
{ content: \_ -> empty
51+
, id: TabId (toLower label)
52+
, label
53+
, count: (7*(i - 1) * (i - 1) `mod` 4) * 7 <$ guard (i `mod` 3 /= 1)
54+
, testId: Nothing
55+
}
56+
}
57+
]
5358
}
5459

5560
, h2_ "Demo 2"

src/Lumi/Components/Layouts/Tabs.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Data.Maybe (Maybe(..))
66
import Data.NonEmpty (NonEmpty, oneOf)
77
import Effect (Effect)
88
import Lumi.Components.Tab (TabId, TabKey)
9-
import Lumi.Components.Tab as Tabs
9+
import Lumi.Components.Tab as Tab
1010
import React.Basic (Component, JSX, createComponent, makeStateless)
1111
import React.Basic.DOM as R
1212
import Web.HTML.History (URL)
@@ -31,7 +31,7 @@ tabLayout :: TabLayoutProps -> JSX
3131
tabLayout = makeStateless component render
3232
where
3333
render { currentLocation, navigate, queryKey, tabs, useHash } =
34-
Tabs.tabs
34+
Tab.tabs
3535
{ style: R.css { "paddingLeft": "24px" }
3636
, tabStyle: R.css {}
3737
, selectedTabStyle: R.css {}

src/Lumi/Components/Tab.purs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ styles = jss
218218
{ flex: "0 0 auto"
219219
, display: "flex"
220220
, alignItems: "center"
221-
, fontSize: "14px"
221+
, fontSize: "14px "
222222
, cursor: "pointer"
223223
, whiteSpace: "nowrap"
224224
, touchAction: "manipulation"
@@ -261,6 +261,13 @@ styles = jss
261261

262262
, "& > lumi-tab:not(:first-child)": { marginLeft: "22px" }
263263
, "&[data-variant=\"full\"] lumi-tab": { marginLeft: "22px" }
264+
265+
-- hide the horizontal scrollbar, it overlaps the tab content
266+
, "&::-webkit-scrollbar":
267+
{ height: "0 !important"
268+
}
269+
, scrollbarWidth: "none"
270+
, "MsOverflowStyle": "none"
264271
}
265272

266273
, "lumi-tab-content":

0 commit comments

Comments
 (0)