Skip to content
This repository was archived by the owner on Nov 19, 2023. It is now read-only.

Commit 33fa768

Browse files
authored
feat: scrollbars (#249)
1 parent 1f7a892 commit 33fa768

File tree

6 files changed

+114
-6
lines changed

6 files changed

+114
-6
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"react-ace": "10.1.0",
4747
"react-beautiful-dnd": "13.1.1",
4848
"react-country-flag": "3.0.2",
49+
"react-custom-scrollbars-2": "^4.5.0",
4950
"react-dom": "18.2.0",
5051
"react-hook-form": "^7.41.0",
5152
"react-router-dom": "6.5.0",

src/components/atoms/Text.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const interactionStyle = css`
6868
export const Text = styled.span.attrs<TextProps>(({ theme, ...props }) => ({
6969
style: {
7070
color: props.color,
71-
fontSize: props.size ? theme?.size?.(props.size) : undefined,
71+
fontSize: theme?.size?.(props.size),
7272
lineHeight: lineHeightStyle(props.lineHeight),
7373
},
7474
}))<TextProps>`

src/components/molecules/VersionPicker.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { useDebounce } from 'use-debounce'
1313
import { observer } from 'mobx-react'
1414
import { useI18N } from 'hooks'
1515
import { Checkbox } from 'components/atoms/Checkbox'
16+
import { Scrollbar } from 'components/utils/Scrollbar'
1617

1718
export interface LargePickerProps<T> extends ExtraProps.Styled {
1819
providers: Array<{
@@ -43,14 +44,13 @@ const VersionsContainer = styled.div`
4344
overflow: hidden;
4445
`
4546

46-
const VersionList = styled.div`
47+
const VersionList = styled(Scrollbar)`
4748
display: flex;
4849
flex-direction: column;
4950
background-color: ${({ theme }) => theme.master.shade()};
5051
border-radius: ${({ theme }) => theme.radius()};
5152
flex-grow: 1;
52-
height: 0;
53-
overflow-y: scroll;
53+
height: calc(38px * 5);
5454
`
5555

5656
interface VersionProps {

src/components/utils/Scrollbar.tsx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { forwardRef } from 'react'
2+
import Scrollbars, { ScrollbarProps } from 'react-custom-scrollbars-2'
3+
import { useTheme } from 'styled-components'
4+
import { rgba } from 'polished'
5+
6+
export const Scrollbar = forwardRef<HTMLDivElement, ExtraProps.HasChildren & ScrollbarProps & ExtraProps.Styled>(
7+
({ children, className, style, ...props }, ref) => {
8+
const theme = useTheme()
9+
const estyle = style
10+
return (
11+
<Scrollbars
12+
autoHeight={false}
13+
autoHeightMax={'100%'}
14+
autoHide
15+
thumbMinSize={20}
16+
{...props}
17+
ref={ref as any}
18+
renderView={({ style, ...props }) => <div {...props} style={{ ...style, ...estyle }} className={className} />}
19+
renderTrackVertical={({ style, ...props }) => (
20+
<div
21+
{...props}
22+
style={{
23+
...style,
24+
width: theme.space(),
25+
height: '100%',
26+
right: 0,
27+
top: 0,
28+
display: 'block',
29+
}}
30+
/>
31+
)}
32+
renderThumbVertical={({ style, ...props }) => (
33+
<div
34+
{...props}
35+
style={{
36+
...style,
37+
background: rgba(theme.master.shade(0.3), 0.3),
38+
borderRadius: theme.radius(),
39+
}}
40+
/>
41+
)}
42+
>
43+
{children}
44+
</Scrollbars>
45+
)
46+
},
47+
)

src/screens/Main/JournalSubscreen/JournalSubscreen.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Button } from 'components/atoms/Button'
1010
import { useI18N } from 'hooks'
1111
import { InstancesModule } from 'minecraft/instances'
1212
import { InstanceModule } from 'minecraft/instance'
13+
import { Scrollbar } from 'components/utils/Scrollbar'
1314

1415
const Page = styled(Screen)`
1516
display: flex;
@@ -44,7 +45,7 @@ const Instance = styled.div<InstanceProps>`
4445
color: ${({ active, theme }) => (active ? theme.accent.primary : theme.master.front)};
4546
`
4647

47-
const LinesContainer = styled.div`
48+
const LinesContainer = styled(Scrollbar)`
4849
position: relative;
4950
display: flex;
5051
flex-direction: column;

yarn.lock

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4513,6 +4513,11 @@ acorn@^8.5.0, acorn@^8.6.0:
45134513
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.1.tgz#0a3f9cbecc4ec3bea6f0a80b66ae8dd2da250b73"
45144514
integrity sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==
45154515

4516+
add-px-to-style@1.0.0:
4517+
version "1.0.0"
4518+
resolved "https://registry.yarnpkg.com/add-px-to-style/-/add-px-to-style-1.0.0.tgz#d0c135441fa8014a8137904531096f67f28f263a"
4519+
integrity sha512-YMyxSlXpPjD8uWekCQGuN40lV4bnZagUwqa2m/uFv1z/tNImSk9fnXVMUI5qwME/zzI3MMQRvjZ+69zyfSSyew==
4520+
45164521
address@^1.0.1:
45174522
version "1.2.2"
45184523
resolved "https://registry.yarnpkg.com/address/-/address-1.2.2.tgz#2b5248dac5485a6390532c6a517fda2e3faac89e"
@@ -6467,6 +6472,15 @@ dom-converter@^0.2.0:
64676472
dependencies:
64686473
utila "~0.4"
64696474

6475+
dom-css@^2.0.0:
6476+
version "2.1.0"
6477+
resolved "https://registry.yarnpkg.com/dom-css/-/dom-css-2.1.0.tgz#fdbc2d5a015d0a3e1872e11472bbd0e7b9e6a202"
6478+
integrity sha512-w9kU7FAbaSh3QKijL6n59ofAhkkmMJ31GclJIz/vyQdjogfyxcB6Zf8CZyibOERI5o0Hxz30VmJS7+7r5fEj2Q==
6479+
dependencies:
6480+
add-px-to-style "1.0.0"
6481+
prefix-style "2.0.1"
6482+
to-camel-case "1.0.0"
6483+
64706484
dom-helpers@^5.0.1:
64716485
version "5.2.1"
64726486
resolved "https://registry.yarnpkg.com/dom-helpers/-/dom-helpers-5.2.1.tgz#d9400536b2bf8225ad98fe052e029451ac40e902"
@@ -11285,6 +11299,11 @@ pbkdf2@^3.0.3:
1128511299
safe-buffer "^5.0.1"
1128611300
sha.js "^2.4.8"
1128711301

11302+
performance-now@^2.1.0:
11303+
version "2.1.0"
11304+
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
11305+
integrity sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==
11306+
1128811307
picocolors@^0.2.1:
1128911308
version "0.2.1"
1129011309
resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-0.2.1.tgz#570670f793646851d1ba135996962abad587859f"
@@ -11463,6 +11482,11 @@ postcss@^8.4.20:
1146311482
picocolors "^1.0.0"
1146411483
source-map-js "^1.0.2"
1146511484

11485+
prefix-style@2.0.1:
11486+
version "2.0.1"
11487+
resolved "https://registry.yarnpkg.com/prefix-style/-/prefix-style-2.0.1.tgz#66bba9a870cfda308a5dc20e85e9120932c95a06"
11488+
integrity sha512-gdr1MBNVT0drzTq95CbSNdsrBDoHGlb2aDJP/FoY+1e+jSDPOb1Cv554gH2MGiSr2WTcXi/zu+NaFzfcHQkfBQ==
11489+
1146611490
prelude-ls@^1.2.1:
1146711491
version "1.2.1"
1146811492
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
@@ -11596,7 +11620,7 @@ prompts@^2.0.1, prompts@^2.4.0:
1159611620
kleur "^3.0.3"
1159711621
sisteransi "^1.0.5"
1159811622

11599-
prop-types@^15.0.0, prop-types@^15.6.0, prop-types@^15.6.2, prop-types@^15.7.2, prop-types@^15.8.1:
11623+
prop-types@^15.0.0, prop-types@^15.5.10, prop-types@^15.6.0, prop-types@^15.6.2, prop-types@^15.7.2, prop-types@^15.8.1:
1160011624
version "15.8.1"
1160111625
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5"
1160211626
integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==
@@ -11724,6 +11748,13 @@ raf-schd@^4.0.2:
1172411748
resolved "https://registry.yarnpkg.com/raf-schd/-/raf-schd-4.0.3.tgz#5d6c34ef46f8b2a0e880a8fcdb743efc5bfdbc1a"
1172511749
integrity sha512-tQkJl2GRWh83ui2DiPTJz9wEiMN20syf+5oKfB03yYP7ioZcJwsIK8FjrtLwH1m7C7e+Tt2yYBlrOpdT+dyeIQ==
1172611750

11751+
raf@^3.1.0:
11752+
version "3.4.1"
11753+
resolved "https://registry.yarnpkg.com/raf/-/raf-3.4.1.tgz#0742e99a4a6552f445d73e3ee0328af0ff1ede39"
11754+
integrity sha512-Sq4CW4QhwOHE8ucn6J34MqtZCeWFP2aQSmrlroYgqAV1PjStIhJXxYuTgUIfkEk7zTLjmIjLmU5q+fbD1NnOJA==
11755+
dependencies:
11756+
performance-now "^2.1.0"
11757+
1172711758
ramda@^0.28.0:
1172811759
version "0.28.0"
1172911760
resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.28.0.tgz#acd785690100337e8b063cab3470019be427cc97"
@@ -11796,6 +11827,15 @@ react-country-flag@3.0.2:
1179611827
resolved "https://registry.yarnpkg.com/react-country-flag/-/react-country-flag-3.0.2.tgz#54c37abe2c87251e95b0f40bb4c09b000f4669e7"
1179711828
integrity sha512-JPaz+q3QD0/nZtHBKj5x3O7r/SgSG9kxbymdaIU0RqlDAcorJIe4KV0DFhWIdKh69q5cPVkIVERcMYGZdvXgAA==
1179811829

11830+
react-custom-scrollbars-2@^4.5.0:
11831+
version "4.5.0"
11832+
resolved "https://registry.yarnpkg.com/react-custom-scrollbars-2/-/react-custom-scrollbars-2-4.5.0.tgz#cff18e7368bce9d570aea0be780045eda392c745"
11833+
integrity sha512-/z0nWAeXfMDr4+OXReTpYd1Atq9kkn4oI3qxq3iMXGQx1EEfwETSqB8HTAvg1X7dEqcCachbny1DRNGlqX5bDQ==
11834+
dependencies:
11835+
dom-css "^2.0.0"
11836+
prop-types "^15.5.10"
11837+
raf "^3.1.0"
11838+
1179911839
react-docgen-typescript@^2.1.1:
1180011840
version "2.2.2"
1180111841
resolved "https://registry.yarnpkg.com/react-docgen-typescript/-/react-docgen-typescript-2.2.2.tgz#4611055e569edc071204aadb20e1c93e1ab1659c"
@@ -13360,11 +13400,23 @@ to-arraybuffer@^1.0.0:
1336013400
resolved "https://registry.yarnpkg.com/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz#7d229b1fcc637e466ca081180836a7aabff83f43"
1336113401
integrity sha512-okFlQcoGTi4LQBG/PgSYblw9VOyptsz2KJZqc6qtgGdes8VktzUQkj4BI2blit072iS8VODNcMA+tvnS9dnuMA==
1336213402

13403+
to-camel-case@1.0.0:
13404+
version "1.0.0"
13405+
resolved "https://registry.yarnpkg.com/to-camel-case/-/to-camel-case-1.0.0.tgz#1a56054b2f9d696298ce66a60897322b6f423e46"
13406+
integrity sha512-nD8pQi5H34kyu1QDMFjzEIYqk0xa9Alt6ZfrdEMuHCFOfTLhDG5pgTu/aAM9Wt9lXILwlXmWP43b8sav0GNE8Q==
13407+
dependencies:
13408+
to-space-case "^1.0.0"
13409+
1336313410
to-fast-properties@^2.0.0:
1336413411
version "2.0.0"
1336513412
resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e"
1336613413
integrity sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==
1336713414

13415+
to-no-case@^1.0.0:
13416+
version "1.0.2"
13417+
resolved "https://registry.yarnpkg.com/to-no-case/-/to-no-case-1.0.2.tgz#c722907164ef6b178132c8e69930212d1b4aa16a"
13418+
integrity sha512-Z3g735FxuZY8rodxV4gH7LxClE4H0hTIyHNIHdk+vpQxjLm0cwnKXq/OFVZ76SOQmto7txVcwSCwkU5kqp+FKg==
13419+
1336813420
to-object-path@^0.3.0:
1336913421
version "0.3.0"
1337013422
resolved "https://registry.yarnpkg.com/to-object-path/-/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af"
@@ -13397,6 +13449,13 @@ to-regex@^3.0.1, to-regex@^3.0.2:
1339713449
regex-not "^1.0.2"
1339813450
safe-regex "^1.1.0"
1339913451

13452+
to-space-case@^1.0.0:
13453+
version "1.0.0"
13454+
resolved "https://registry.yarnpkg.com/to-space-case/-/to-space-case-1.0.0.tgz#b052daafb1b2b29dc770cea0163e5ec0ebc9fc17"
13455+
integrity sha512-rLdvwXZ39VOn1IxGL3V6ZstoTbwLRckQmn/U8ZDLuWwIXNpuZDhQ3AiRUlhTbOXFVE9C+dR51wM0CBDhk31VcA==
13456+
dependencies:
13457+
to-no-case "^1.0.0"
13458+
1340013459
toidentifier@1.0.1:
1340113460
version "1.0.1"
1340213461
resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35"

0 commit comments

Comments
 (0)