Skip to content

Commit 70ccf88

Browse files
committed
feat: adornment
1 parent 91d5df6 commit 70ccf88

File tree

5 files changed

+67
-15
lines changed

5 files changed

+67
-15
lines changed

example/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@
2222
"@types/jest": "link:../node_modules/@types/jest",
2323
"@types/node": "link:../node_modules/@types/node",
2424
"@types/react-dom": "link:../node_modules/@types/react-dom",
25+
"@types/react-icons": "link:../node_modules/@types/react-icons",
2526
"@types/react": "link:../node_modules/@types/react",
2627
"framer-motion": "link:../node_modules/framer-motion",
2728
"react-dom": "link:../node_modules/react-dom",
2829
"react-scripts": "link:../node_modules/react-scripts",
30+
"react-icons": "link:../node_modules/react-icons",
2931
"react": "link:../node_modules/react",
3032
"typescript": "link:../node_modules/typescript"
3133
},

example/yarn.lock

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,28 +2077,28 @@
20772077
minimatch "^3.1.2"
20782078
strip-json-comments "^3.1.1"
20792079

2080-
"@floating-ui/core@^1.0.1":
2081-
version "1.0.1"
2082-
resolved "https://registry.yarnpkg.com/@floating-ui/core/-/core-1.0.1.tgz#00e64d74e911602c8533957af0cce5af6b2e93c8"
2083-
integrity sha512-bO37brCPfteXQfFY0DyNDGB3+IMe4j150KFQcgJ5aBP295p9nBGeHEs/p0czrRbtlHq4Px/yoPXO/+dOCcF4uA==
2080+
"@floating-ui/core@^1.2.2":
2081+
version "1.2.2"
2082+
resolved "https://registry.yarnpkg.com/@floating-ui/core/-/core-1.2.2.tgz#66f62cf1b7de2ed23a09c101808536e68caffaec"
2083+
integrity sha512-FaO9KVLFnxknZaGWGmNtjD2CVFuc0u4yeGEofoyXO2wgRA7fLtkngT6UB0vtWQWuhH3iMTZZ/Y89CMeyGfn8pA==
20842084

2085-
"@floating-ui/dom@^1.0.0":
2086-
version "1.0.3"
2087-
resolved "https://registry.yarnpkg.com/@floating-ui/dom/-/dom-1.0.3.tgz#b439c8a66436c2cae8d97e889f0b76cce757a6ec"
2088-
integrity sha512-6H1kwjkOZKabApNtXRiYHvMmYJToJ1DV7rQ3xc/WJpOABhQIOJJOdz2AOejj8X+gcybaFmBpisVTZxBZAM3V0w==
2085+
"@floating-ui/dom@^1.2.1":
2086+
version "1.2.3"
2087+
resolved "https://registry.yarnpkg.com/@floating-ui/dom/-/dom-1.2.3.tgz#8dc6fbf799fbb5c29f705b54bdd51f3ab0ee03a2"
2088+
integrity sha512-lK9cZUrHSJLMVAdCvDqs6Ug8gr0wmqksYiaoj/bxj2gweRQkSuhg2/V6Jswz2KiQ0RAULbqw1oQDJIMpQ5GfGA==
20892089
dependencies:
2090-
"@floating-ui/core" "^1.0.1"
2090+
"@floating-ui/core" "^1.2.2"
20912091

20922092
"@floating-ui/react-dom-interactions@link:../node_modules/@floating-ui/react-dom-interactions":
20932093
version "0.0.0"
20942094
uid ""
20952095

2096-
"@floating-ui/react-dom@^1.0.0":
2097-
version "1.0.0"
2098-
resolved "https://registry.yarnpkg.com/@floating-ui/react-dom/-/react-dom-1.0.0.tgz#e0975966694433f1f0abffeee5d8e6bb69b7d16e"
2099-
integrity sha512-uiOalFKPG937UCLm42RxjESTWUVpbbatvlphQAU6bsv+ence6IoVG8JOUZcy8eW81NkU+Idiwvx10WFLmR4MIg==
2096+
"@floating-ui/react-dom@^1.0.1":
2097+
version "1.3.0"
2098+
resolved "https://registry.yarnpkg.com/@floating-ui/react-dom/-/react-dom-1.3.0.tgz#4d35d416eb19811c2b0e9271100a6aa18c1579b3"
2099+
integrity sha512-htwHm67Ji5E/pROEAr7f8IKFShuiCKHwUC/UY4vC3I5jiSvGFAYnSYiZO5MlGmads+QqvUkR9ANHEguGrDv72g==
21002100
dependencies:
2101-
"@floating-ui/dom" "^1.0.0"
2101+
"@floating-ui/dom" "^1.2.1"
21022102

21032103
"@gar/promisify@^1.0.1":
21042104
version "1.1.3"
@@ -4193,6 +4193,10 @@
41934193
version "0.0.0"
41944194
uid ""
41954195

4196+
"@types/react-icons@link:../node_modules/@types/react-icons":
4197+
version "0.0.0"
4198+
uid ""
4199+
41964200
"@types/react-syntax-highlighter@11.0.5":
41974201
version "11.0.5"
41984202
resolved "https://registry.yarnpkg.com/@types/react-syntax-highlighter/-/react-syntax-highlighter-11.0.5.tgz#0d546261b4021e1f9d85b50401c0a42acb106087"
@@ -12881,6 +12885,15 @@ react-helmet-async@^1.0.7:
1288112885
react-fast-compare "^3.2.0"
1288212886
shallowequal "^1.1.0"
1288312887

12888+
react-icons@*:
12889+
version "4.8.0"
12890+
resolved "https://registry.yarnpkg.com/react-icons/-/react-icons-4.8.0.tgz#621e900caa23b912f737e41be57f27f6b2bff445"
12891+
integrity sha512-N6+kOLcihDiAnj5Czu637waJqSnwlMNROzVZMhfX68V/9bu9qHaMIJC4UdozWoOk57gahFCNHwVvWzm0MTzRjg==
12892+
12893+
"react-icons@link:../node_modules/react-icons":
12894+
version "0.0.0"
12895+
uid ""
12896+
1288412897
react-inspector@^5.1.0:
1288512898
version "5.1.1"
1288612899
resolved "https://registry.yarnpkg.com/react-inspector/-/react-inspector-5.1.1.tgz#58476c78fde05d5055646ed8ec02030af42953c8"
@@ -14343,6 +14356,11 @@ synchronous-promise@^2.0.15:
1434314356
resolved "https://registry.yarnpkg.com/synchronous-promise/-/synchronous-promise-2.0.15.tgz#07ca1822b9de0001f5ff73595f3d08c4f720eb8e"
1434414357
integrity sha512-k8uzYIkIVwmT+TcglpdN50pS2y1BDcUnBPK9iJeGu0Pl1lOI8pD6wtzgw91Pjpe+RxtTncw32tLxs/R0yNL2Mg==
1434514358

14359+
tabbable@^6.0.1:
14360+
version "6.1.1"
14361+
resolved "https://registry.yarnpkg.com/tabbable/-/tabbable-6.1.1.tgz#40cfead5ed11be49043f04436ef924c8890186a0"
14362+
integrity sha512-4kl5w+nCB44EVRdO0g/UGoOp3vlwgycUVtkk/7DPyeLZUCuNFFKCFG6/t/DgHLrUPHjrZg6s5tNm+56Q2B0xyg==
14363+
1434614364
tailwindcss@^3.0.2:
1434714365
version "3.0.24"
1434814366
resolved "https://registry.yarnpkg.com/tailwindcss/-/tailwindcss-3.0.24.tgz#22e31e801a44a78a1d9a81ecc52e13b69d85704d"

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
"@floating-ui/react-dom-interactions": "^0.13.3",
3535
"framer-motion": "6.x",
3636
"react": ">=17",
37-
"react-dom": ">=17"
37+
"react-dom": ">=17",
38+
"react-icons": "^4.8.0"
3839
},
3940
"devDependencies": {
4041
"@babel/plugin-proposal-decorators": "^7.17.9",
@@ -49,6 +50,7 @@
4950
"@types/node": "^12.12.38",
5051
"@types/react": "^18.0.9",
5152
"@types/react-dom": "^18.0.3",
53+
"@types/react-icons": "^3.0.0",
5254
"@typescript-eslint/eslint-plugin": "^5.22.0",
5355
"@typescript-eslint/parser": "^5.22.0",
5456
"babel-eslint": "^10.0.3",
@@ -78,6 +80,7 @@
7880
"prettier": "^2.6.2",
7981
"react": "^17.0.1",
8082
"react-dom": "^17.0.1",
83+
"react-icons": "^4.8.0",
8184
"react-scripts": "^5.0.1",
8285
"typescript": "^4.6.4"
8386
}

src/components/Select.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,24 @@ import React, {
3131
useRef,
3232
useState
3333
} from 'react'
34+
import { IoChevronDown } from 'react-icons/io5'
3435
import { PC, PP, PR } from '../types/PolymorphicElementProps'
3536
import { cssClickable, cssDisablable } from '../utils/styles'
3637
import { ListItem, ListItemProps } from './$List'
38+
import { Centering } from './Centering'
3739

3840
interface SelectDisplayProps {
3941
fullWidth: boolean
4042
ellipsis: boolean
4143
}
4244

45+
// TODO add style variables
46+
4347
const SelectDisplay = styled.div<SelectDisplayProps>`
4448
${cssDisablable}
4549
${cssClickable}
4650
${({ ellipsis: enableEllipsis }) => enableEllipsis && ellipsis()}
51+
position: relative;
4752
display: inline-block;
4853
font-family: inherit;
4954
height: auto;
@@ -69,6 +74,15 @@ const SelectItemsWrapper = styled(motion.div)`
6974
max-width: 100vw;
7075
`
7176

77+
const SelectInputAdornment = styled(Centering)`
78+
position: absolute;
79+
right: 0;
80+
top: 0;
81+
bottom: 0;
82+
width: 48px;
83+
color: ${({ theme }) => theme.color.text.secondary.main};
84+
`
85+
7286
// Adopted from https://codesandbox.io/s/shy-snowflake-kp6479?file=/src/Select.tsx:5939-5954
7387

7488
type SelectItemNode = string | { value: string }
@@ -280,6 +294,9 @@ export const Select: PC<'button', SelectProps> = React.forwardRef(
280294
{...rest}
281295
>
282296
{selected ? render(selected) : null}
297+
<SelectInputAdornment>
298+
<IoChevronDown />
299+
</SelectInputAdornment>
283300
</SelectDisplay>
284301
<FloatingPortal>
285302
<AnimatePresence>

yarn.lock

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2304,6 +2304,13 @@
23042304
dependencies:
23052305
"@types/react" "*"
23062306

2307+
"@types/react-icons@^3.0.0":
2308+
version "3.0.0"
2309+
resolved "https://registry.yarnpkg.com/@types/react-icons/-/react-icons-3.0.0.tgz#27ca2823a6add881d06a371bfff093afc1b9c829"
2310+
integrity sha512-Vefs6LkLqF61vfV7AiAqls+vpR94q67gunhMueDznG+msAkrYgRxl7gYjNem/kZ+as2l2mNChmF1jRZzzQQtMg==
2311+
dependencies:
2312+
react-icons "*"
2313+
23072314
"@types/react@*":
23082315
version "18.0.6"
23092316
resolved "https://registry.npmjs.org/@types/react/-/react-18.0.6.tgz"
@@ -8420,6 +8427,11 @@ react-error-overlay@^6.0.11:
84208427
resolved "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.11.tgz"
84218428
integrity sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg==
84228429

8430+
react-icons@*, react-icons@^4.8.0:
8431+
version "4.8.0"
8432+
resolved "https://registry.yarnpkg.com/react-icons/-/react-icons-4.8.0.tgz#621e900caa23b912f737e41be57f27f6b2bff445"
8433+
integrity sha512-N6+kOLcihDiAnj5Czu637waJqSnwlMNROzVZMhfX68V/9bu9qHaMIJC4UdozWoOk57gahFCNHwVvWzm0MTzRjg==
8434+
84238435
react-is@^16.12.0, react-is@^16.13.1, react-is@^16.7.0, react-is@^16.8.4:
84248436
version "16.13.1"
84258437
resolved "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz"

0 commit comments

Comments
 (0)