-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add VersionsSelect component (#383)
- Loading branch information
1 parent
d93594a
commit a4f3c7a
Showing
19 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React, {useCallback, useState} from 'react'; | ||
import {Select} from '@gravity-ui/uikit'; | ||
|
||
import {useTranslation} from '../../hooks'; | ||
|
||
export interface VersionsSelectProps { | ||
version: string; | ||
versions: string[]; | ||
onChange: (version: string) => void; | ||
className?: string; | ||
} | ||
|
||
export const VersionsSelect: React.FC<VersionsSelectProps> = (props) => { | ||
const {version: defaultVersion, versions, className, onChange} = props; | ||
const [version, setVersion] = useState<string>(defaultVersion); | ||
|
||
const {t} = useTranslation('header'); | ||
|
||
const onUpdate = useCallback( | ||
(selected: string[]) => { | ||
onChange(selected[0]); | ||
setVersion(selected[0]); | ||
}, | ||
[onChange, setVersion], | ||
); | ||
|
||
return ( | ||
<Select | ||
placeholder={t('versions-select-placeholder')} | ||
value={[version]} | ||
options={versions.map((value) => ({value, content: value}))} | ||
onUpdate={onUpdate} | ||
className={className} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './VersionsSelect'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,5 +133,8 @@ | |
}, | ||
"updated-at-date": { | ||
"title": "Aktualizováno na" | ||
}, | ||
"header": { | ||
"versions-select-placeholder": "Verze" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,5 +133,8 @@ | |
}, | ||
"updated-at-date": { | ||
"title": "Updated at" | ||
}, | ||
"header": { | ||
"versions-select-placeholder": "Versions" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,5 +133,8 @@ | |
}, | ||
"updated-at-date": { | ||
"title": "Mis à jour à" | ||
}, | ||
"header": { | ||
"versions-select-placeholder": "Versions" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,5 +133,8 @@ | |
}, | ||
"updated-at-date": { | ||
"title": "Обновлена" | ||
}, | ||
"header": { | ||
"versions-select-placeholder": "Версии" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,5 +130,8 @@ | |
"paginator": { | ||
"next": "下一頁", | ||
"prev": "上一頁" | ||
}, | ||
"header": { | ||
"versions-select-placeholder": "版本" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,5 +130,8 @@ | |
"paginator": { | ||
"next": "下一页", | ||
"prev": "上一页" | ||
}, | ||
"header": { | ||
"versions-select-placeholder": "版本" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters