1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

feat(onboarding): add links to examples (#8308)

## About the changes
Links from Unleash UI to
[Unleash/unleash-sdk-examples](https://github.com/Unleash/unleash-sdk-examples)


https://linear.app/unleash/issue/1-2869/add-codesandbox-links-to-unleashunleash
This commit is contained in:
Tymoteusz Czech 2024-10-01 12:58:21 +02:00 committed by GitHub
parent ab81528536
commit a6ab5326a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,8 +1,8 @@
import { type SelectChangeEvent, styled, Typography } from '@mui/material';
import { Link } from 'react-router-dom';
import Select from '../../common/select';
import { useState } from 'react';
import { allSdks } from '../dialog/sharedTypes';
import { useLocalStorageState } from 'hooks/useLocalStorageState';
import Select from 'component/common/select';
import { allSdks, type SdkName } from '../dialog/sharedTypes';
const TitleContainer = styled('div')(({ theme }) => ({
display: 'flex',
@ -18,17 +18,40 @@ const StyledLink = styled(Link)({
textDecoration: 'none',
});
const repositoryUrl =
'https://github.com/Unleash/unleash-sdk-examples/tree/main';
type exampleDirectories =
| 'Android'
| '.NET'
| 'Flutter'
| 'Go'
| 'Java'
| 'JavaScript'
| 'Node.js'
| 'PHP'
| 'Python'
| 'React'
| 'Ruby'
| 'Rust'
| 'Svelte'
| 'Swift'
| 'Vue';
export const SdkExample = () => {
const sdkOptions = allSdks.map((sdk) => ({
key: sdk.name,
label: sdk.name,
}));
const [selectedSdk, setSelectedSdk] = useState<string>(sdkOptions[0].key);
const [selectedSdk, setSelectedSdk] =
useLocalStorageState<exampleDirectories>(
'onboarding-sdk-example',
sdkOptions[0].key,
);
const onChange = (event: SelectChangeEvent) => {
setSelectedSdk(event.target.value);
setSelectedSdk(event.target.value as SdkName);
};
return (
<>
<TitleContainer>View SDK Example</TitleContainer>
@ -45,7 +68,9 @@ export const SdkExample = () => {
width: '60%',
}}
/>
<StyledLink to={``}>Go to example</StyledLink>
<StyledLink to={`${repositoryUrl}/${selectedSdk}`} target='_blank'>
Go to example
</StyledLink>
</>
);
};