-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(editor): added editor playground (#258)
- Loading branch information
1 parent
3b2d595
commit ac8d206
Showing
27 changed files
with
1,602 additions
and
17 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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"goToLibrary": "Go to library", | ||
"title": "Editor" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"goToLibrary": "К библиотеке", | ||
"title": "Редактор" | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,64 @@ | ||
import {GetStaticPaths, GetStaticPathsResult, GetStaticProps} from 'next'; | ||
import {useTranslation} from 'next-i18next'; | ||
import React from 'react'; | ||
import {useLocaleRedirect} from 'src/hooks/useLocaleRedirect'; | ||
|
||
import {Layout} from '../../../../components/Layout/Layout'; | ||
import {MarkdownEditor} from '../../../../components/MarkdownEditor/MarkdownEditor'; | ||
import {getI18nPaths, getI18nProps, getLibsList} from '../../../../utils'; | ||
|
||
const libs = getLibsList(); | ||
|
||
export const getStaticPaths: GetStaticPaths = async () => { | ||
const paths = getI18nPaths().reduce<GetStaticPathsResult['paths']>((acc, localeItem) => { | ||
acc.push( | ||
...libs.map((libItem) => ({ | ||
params: {locale: localeItem.params.locale, libId: libItem.config.id}, | ||
})), | ||
); | ||
return acc; | ||
}, []); | ||
|
||
return { | ||
paths, | ||
fallback: false, | ||
}; | ||
}; | ||
|
||
export const getStaticProps: GetStaticProps = async (context) => { | ||
const libId = Array.isArray(context.params?.libId) | ||
? context.params?.libId[0] | ||
: context.params?.libId; | ||
|
||
return { | ||
props: { | ||
libId: libId || null, | ||
...(await getI18nProps(context, ['library', 'libraries-info', libId ?? ''])), | ||
}, | ||
}; | ||
}; | ||
|
||
// TODO: open with article | ||
// export const availablePlaygrounds = ['markdown-editor']; | ||
export const availablePlaygrounds = [] as string[]; | ||
|
||
export const PlaygroundPage = ({libId}: {libId: string}) => { | ||
const hasPlayground = availablePlaygrounds.includes(libId); | ||
|
||
useLocaleRedirect(); | ||
const {t} = useTranslation(); | ||
|
||
return ( | ||
<> | ||
{hasPlayground && ( | ||
<> | ||
<Layout title={availablePlaygrounds.includes(libId) ? t(libId) : ''}> | ||
{libId === 'markdown-editor' && <MarkdownEditor />} | ||
</Layout> | ||
</> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default PlaygroundPage; |
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 |
---|---|---|
@@ -0,0 +1,72 @@ | ||
@use '~@gravity-ui/page-constructor/styles/variables.scss' as pcVariables; | ||
@use '~@gravity-ui/uikit/styles/mixins' as ukitMixins; | ||
@use '../../variables.scss'; | ||
|
||
$block: '.#{variables.$ns}markdown-editor'; | ||
|
||
#{$block} { | ||
margin-block-start: calc(var(--g-spacing-base) * 8); | ||
|
||
&__heading { | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
margin-bottom: pcVariables.$indentXS; | ||
|
||
@media (max-width: map-get(pcVariables.$gridBreakpoints, 'md') - 1) { | ||
margin-bottom: pcVariables.$indentXXXS; | ||
} | ||
} | ||
|
||
&__title { | ||
font-size: 48px; | ||
line-height: 56px; | ||
font-weight: 600; | ||
color: #fff; | ||
margin: 0; | ||
|
||
@media (max-width: map-get(pcVariables.$gridBreakpoints, 'md') - 1) { | ||
font-size: 32px; | ||
line-height: 48px; | ||
margin-bottom: pcVariables.$indentXXXS; | ||
} | ||
} | ||
|
||
&__content { | ||
width: 100%; | ||
min-height: 300px; | ||
} | ||
} | ||
|
||
.g-md-editor-component__editor-wrapper { | ||
border-radius: 10px; | ||
border: 1px solid rgba(255, 255, 255, 0.2); | ||
padding: 15px 20px 20px; | ||
margin-bottom: 20px; | ||
} | ||
|
||
.yfm-editor { | ||
color: var(--g-color-text-primary); | ||
} | ||
|
||
// FIXME: This is a temporary solution, will be fixed after | ||
// https://github.com/gravity-ui/markdown-editor/pull/369 */ | ||
|
||
:root { | ||
--g-md-sticky-offset-compensate: 100px; | ||
} | ||
|
||
.gravity-ui-landing-markdown-editor_sticky .g-md-editor-component__toolbar { | ||
z-index: 2000; | ||
position: sticky; | ||
top: 8px; | ||
} | ||
|
||
.gravity-ui-landing-markdown-editor_sticky .g-md-editor-component__toolbar::before { | ||
position: absolute; | ||
inset: -4px; | ||
content: ''; | ||
border: 1px solid var(--g-color-line-generic-solid); | ||
border-radius: 4px; | ||
background-color: var(--g-color-base-background); | ||
} |
Oops, something went wrong.