-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs(versions): add versions #3486
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
0aed97d
docs(Checkbox): add examples to .mdx
3de264a
docs(Checkbox): add examples to .mdx
28cb039
Merge branch 'mdx-checkbox' of github.com:skbkontur/retail-ui into md…
f39efc3
docs(ValidationContainer): returned deleted screenshot img from Valid…
e9cb6ba
Merge branch 'mdx-exaples-on-storybook-7' into mdx-checkbox
SchwJ 958b8df
fix(): mini-fix indents to start CI tests
SchwJ 06f1821
Merge branch 'mdx-exaples-on-storybook-7' into mdx-checkbox
SchwJ 6206426
docs(Versions): add versions react-ui library
1bc96a8
docs(LocaleDecorator): add locale decarator in storybook
b3ba4da
docs(LocaleDecorator): add hideLocaleBtnInUnsupportedControls
fea442c
docs(LocaleDecorator): add dynamic text with icon, prettier
08fe4db
Merge branch 'mdx-exaples-on-storybook-7' into mdx-toolbar-locale
SchwJ 2be392b
Merge branch 'mdx-exaples-on-storybook-7' into mdx-checkbox
SchwJ aa18c41
chore(Checkbox): fix screenshots
SchwJ a457625
chore(Checkbox): fix screenshots and lint
SchwJ 05b0a55
Merge pull request #3466 from skbkontur/mdx-checkbox
SchwJ 5315b84
chore(): fix merge error
SchwJ ddcceed
chore(): fix lint errors
SchwJ 7cc21b0
docs(featureFlags): update featureFlagsConfig.tsx
a3193de
docs(LocaleDecorator): update LocaleDecorator
65a5de8
Merge pull request #3473 from skbkontur/mdx-toolbar-features
SchwJ 86eb79b
Merge branch 'mdx-exaples-on-storybook-7' into mdx-toolbar-locale
SchwJ f7c5816
Merge pull request #3471 from skbkontur/mdx-toolbar-locale
SchwJ 7e90d78
Merge remote-tracking branch 'origin/mdx-exaples-on-storybook-7' into…
66a27cb
docs(versions): update Versions mdx,tsx
0afbb46
Merge branch 'mdx-exaples-on-storybook-7' into mdx-versions
8ce9224
docs(versions): fix lint
d6978ba
docs(versions): update catch err
d60e023
docs(versions): update error message
ff2701e
docs(versions): update error message
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
packages/react-ui/components/__stories__/Versions/Versions.mdx
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,8 @@ | ||
import { VersionsLibrary } from './Versions'; | ||
import { Meta } from '@storybook/blocks'; | ||
|
||
<Meta title="Versions" /> | ||
|
||
# Версии React UI | ||
|
||
<VersionsLibrary /> |
80 changes: 80 additions & 0 deletions
80
packages/react-ui/components/__stories__/Versions/Versions.tsx
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,80 @@ | ||
import React from 'react'; | ||
|
||
import { Loader } from '../../Loader'; | ||
import { Link } from '../../Link'; | ||
|
||
interface LibraryVersion { | ||
version: string; | ||
path: string; | ||
} | ||
interface ResponseData { | ||
versions: LibraryVersion[]; | ||
} | ||
|
||
const baseUrl = 'https://ui.gitlab-pages.kontur.host/docs/react-ui-storybook'; | ||
const createEndpoint = (path: string) => `${baseUrl}/${path}`; | ||
const jsonEndpoint = createEndpoint('reactUIStorybookVersions.json'); | ||
|
||
const renderLibraryVersionItem = ({ path, version }: LibraryVersion) => { | ||
return ( | ||
<li key={path}> | ||
<Link target="_blank" href={path}> | ||
{version} | ||
</Link> | ||
</li> | ||
); | ||
}; | ||
|
||
const renderLibraryVersions = (libraryVersions: LibraryVersion[]) => { | ||
if (libraryVersions.length === 0) { | ||
return <p>Список версий пуст.</p>; | ||
} | ||
|
||
return <ul>{libraryVersions.map((libraryVersion) => renderLibraryVersionItem(libraryVersion))}</ul>; | ||
}; | ||
|
||
const renderErrorMessage = (errMessage?: string) => { | ||
return ( | ||
<> | ||
<p style={{ margin: '0' }}>Не удалось загрузить список версий.</p> | ||
<p style={{ margin: '0' }}>{errMessage ? `Ошибка при запросе: ${errMessage}.` : 'Ошибка при запросе.'}</p> | ||
</> | ||
); | ||
}; | ||
|
||
export const VersionsLibrary = () => { | ||
const [errMessage, setErrorMessage] = React.useState(''); | ||
const [libraryVersions, setLibraryVersions] = React.useState<LibraryVersion[]>([]); | ||
const [isLoading, setIsLoading] = React.useState(false); | ||
|
||
React.useEffect(() => { | ||
const fetchAllVersionsLibrary = async () => { | ||
try { | ||
setIsLoading(true); | ||
const response = await fetch(jsonEndpoint); | ||
if (!response.ok) { | ||
setErrorMessage(`${response.status}`); | ||
setLibraryVersions([]); | ||
return; | ||
} | ||
const { versions }: ResponseData = await response.json(); | ||
setErrorMessage(''); | ||
setLibraryVersions(versions); | ||
} catch (err) { | ||
setErrorMessage(err?.message); | ||
setLibraryVersions([]); | ||
} finally { | ||
setIsLoading(false); | ||
} | ||
}; | ||
|
||
void fetchAllVersionsLibrary(); | ||
}, []); | ||
|
||
return ( | ||
<Loader active={isLoading}> | ||
{errMessage && renderErrorMessage(errMessage)} | ||
{!errMessage && !isLoading && renderLibraryVersions(libraryVersions)} | ||
</Loader> | ||
); | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Давай запишем это в несколько строчек: ul и его содержимое. Код, записанный так, более удобно читать
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
При запуске prettier все собирается в 1 строчку
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌