summaryrefslogtreecommitdiff
path: root/src/components/Selection.js
diff options
context:
space:
mode:
authorHaishan <[email protected]>2020-10-31 18:18:04 +0800
committerHaishan <[email protected]>2020-11-01 17:42:52 +0800
commitff1a39d04e53b428e34d46c55ecd6689189b5443 (patch)
tree94a60abe3d28a1d729b877356bdd38d75ce655a5 /src/components/Selection.js
parente62c9165481ef12ee2310dee1c32f890b3fe4b78 (diff)
chore: run ts-migrate
Diffstat (limited to 'src/components/Selection.js')
-rw-r--r--src/components/Selection.js61
1 files changed, 0 insertions, 61 deletions
diff --git a/src/components/Selection.js b/src/components/Selection.js
deleted file mode 100644
index 764e7b3..0000000
--- a/src/components/Selection.js
+++ /dev/null
@@ -1,61 +0,0 @@
-import cx from 'clsx';
-import { array, func, number } from 'prop-types';
-import React from 'react';
-
-import s from './Selection.module.css';
-
-export default function Selection({
- OptionComponent,
- optionPropsList,
- selectedIndex,
- onChange,
-}) {
- return (
- <div className={s.root}>
- {optionPropsList.map((props, idx) => {
- const className = cx(s.item, { [s.itemActive]: idx === selectedIndex });
- const doSelect = (ev) => {
- ev.preventDefault();
- if (idx !== selectedIndex) onChange(idx);
- };
- return (
- <div
- key={idx}
- className={className}
- tabIndex={0}
- role="menuitem"
- onKeyDown={doSelect}
- onClick={doSelect}
- >
- <OptionComponent {...props} />
- </div>
- );
- })}
- </div>
- );
-}
-
-Selection.propTypes = {
- OptionComponent: func,
- optionPropsList: array,
- selectedIndex: number,
- onChange: func,
-};
-
-// for test
-export function Option({ title }) {
- // eslint-disable-next-line no-undef
- if (__DEV__) {
- return (
- <div
- style={{
- width: 100,
- height: 60,
- backgroundColor: '#eee',
- }}
- >
- {title}
- </div>
- );
- }
-}