mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
#57 added block-based content editor
This commit is contained in:
parent
4b542e0291
commit
d8c379de6a
17 changed files with 302 additions and 13 deletions
27
src/containers/editors/NewEditorBlockVideo/index.tsx
Normal file
27
src/containers/editors/NewEditorBlockVideo/index.tsx
Normal file
|
@ -0,0 +1,27 @@
|
|||
import React, { FC, useCallback, useMemo } from 'react';
|
||||
import { getYoutubeThumb } from '~/utils/dom';
|
||||
import styles from './styles.module.scss';
|
||||
import classnames from 'classnames';
|
||||
import { InputText } from '~/components/input/InputText';
|
||||
import { BlockType, IBlockComponentProps } from '~/redux/types';
|
||||
|
||||
const NewEditorBlockVideo: FC<IBlockComponentProps> = ({ block, handler }) => {
|
||||
const setUrl = useCallback((url: string) => handler({ type: BlockType.video, url }), [handler]);
|
||||
|
||||
const url = block.url || '';
|
||||
const preview = useMemo(() => getYoutubeThumb(url), [url]);
|
||||
const backgroundImage = (preview && `url("${preview}")`) || '';
|
||||
|
||||
return (
|
||||
<div className={styles.wrap}>
|
||||
<div className={styles.input_wrap}>
|
||||
<div className={classnames(styles.input, { active: !!preview })}>
|
||||
<InputText value={url} handler={setUrl} placeholder="Адрес видео" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className={styles.preview} style={{ backgroundImage }} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
export { NewEditorBlockVideo };
|
|
@ -0,0 +1,33 @@
|
|||
@import "src/styles/variables";
|
||||
|
||||
.wrap {
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
.preview {
|
||||
padding-top: 56.25%;
|
||||
position: relative;
|
||||
border-radius: $radius;
|
||||
background: 50% 50% no-repeat;
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
.input_wrap {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.input {
|
||||
flex: 1 0 50%;
|
||||
padding: $gap;
|
||||
background: lighten($content_bg, 4%);
|
||||
border-radius: $radius $radius 0 0;
|
||||
input {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
&:global(.active) {
|
||||
background: $red;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue