Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
e5d52a8
feat: very early working version
gorgeousvlad May 25, 2023
a5f54a4
feat: add all blocks for content form and fix render loop
gorgeousvlad May 26, 2023
5ab36e7
fix: refactor editor string id to index
gorgeousvlad May 26, 2023
96fed3c
feat: add form block selection
gorgeousvlad May 26, 2023
6196293
fix: add block form folding on selection
gorgeousvlad May 26, 2023
943e96f
feat: editor form layout pt.1
gorgeousvlad May 29, 2023
ed9c0f2
feat: add properties ordering
gorgeousvlad May 29, 2023
93fc0d8
fix: refactor form schemas transform and fix bug
gorgeousvlad May 29, 2023
e4548c1
fix: content layout properties deprecation
gorgeousvlad May 30, 2023
9e3edc6
feat: add handling
gorgeousvlad May 30, 2023
ab69d8e
fix: blocks shemas
gorgeousvlad May 31, 2023
6f53304
feat: add custom OneOf dynamic form component
gorgeousvlad Jun 2, 2023
e2b3320
fix: one of custom styles
gorgeousvlad Jun 2, 2023
add51d9
fix: replace anyOf with oneOf in schemas
gorgeousvlad Jun 2, 2023
7c64496
feat: add children cards pt.1
gorgeousvlad Jun 4, 2023
e51e52e
fix: refactor form schema parser
gorgeousvlad Jun 4, 2023
da21f66
fix: reserved field name
gorgeousvlad Jun 5, 2023
2efad95
fix: media schema themes
gorgeousvlad Jun 5, 2023
d3a4fcc
fix: disable loadable in editor, remove smooth scroll and fix editor …
gorgeousvlad Jun 5, 2023
51184a5
fix: refactor form spec parser pt.1
gorgeousvlad Jun 6, 2023
38fd359
fix: form styles
gorgeousvlad Jun 7, 2023
b07a1aa
fix: number validation
gorgeousvlad Jun 7, 2023
7c00590
fix: rename forms directory
gorgeousvlad Jun 8, 2023
09077ba
fix: move block form
gorgeousvlad Jun 8, 2023
db42ed8
fix: post rebase
gorgeousvlad Jun 8, 2023
378a725
fix: refactor block decoration inde
gorgeousvlad Jun 8, 2023
6ef6d9c
fix: add editor form schema types
gorgeousvlad Jun 8, 2023
c178ddd
fix: dont clone child definitions in form parser
gorgeousvlad Jun 8, 2023
6db2e5d
fix: form custom component hook deps warnings
gorgeousvlad Jun 8, 2023
229f22d
fix: card layout template
gorgeousvlad Jun 8, 2023
0db9cec
feat: add default values to form and fix price detailed schemas
gorgeousvlad Jun 8, 2023
9a54994
fix: input styles, table fields schema and template data
gorgeousvlad Jun 8, 2023
54eaf41
fix: remove unused types
gorgeousvlad Jun 9, 2023
74603d8
fix: directory case names problem
gorgeousvlad Jun 9, 2023
705ff02
fix: one of default values
gorgeousvlad Jun 9, 2023
1c12b2d
fix: review
gorgeousvlad Jun 9, 2023
ef83bf3
fix: design review
gorgeousvlad Jun 9, 2023
cf8a7c1
feat: pass constructor data to editor callback
gorgeousvlad Jun 9, 2023
14576a6
docs: add docs for parser and editor block addition
gorgeousvlad Jun 9, 2023
12ca769
feat: add page properties form
gorgeousvlad Jun 12, 2023
c94b547
fix: code review pt.2
gorgeousvlad Jun 13, 2023
f14842d
fix: code review pt.3
gorgeousvlad Jun 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ Sub-blocks are components that can be used in the block `children` property. In

6. In the block directory, add the `README.md` file with a description of input parameters.
7. In the block directory add storybook demo in `__stories__` folder. All demo content for story should be placed in `data.json` at story dir. The generic `Story` must accept the type of block props, otherwise incorrect block props will be displayed in Storybook.
8. Add block data template to `src/editor/data/templates/` folder, file name should match block type
9. (optional) Add block preview icon to `src/editor/data/previews/` folder, file name should match block type

### Themes

Expand Down
34 changes: 31 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@
"dependencies": {
"@gravity-ui/i18n": "^1.0.0",
"bem-cn-lite": "^4.0.0",
"final-form": "^4.20.9",
"github-buttons": "2.23.0",
"lodash": "^4.17.21",
"react-final-form": "^6.5.9",
"react-player": "^2.9.0",
"react-slick": "^0.28.1",
"react-spring": "^9.3.0",
Expand All @@ -69,6 +71,7 @@
"@commitlint/cli": "^17.1.2",
"@commitlint/config-conventional": "^17.1.0",
"@doc-tools/transform": "2.12.0",
"@gravity-ui/dynamic-forms": "^1.7.1",
"@gravity-ui/eslint-config": "^2.0.0",
"@gravity-ui/icons": "^2.1.0",
"@gravity-ui/prettier-config": "^1.0.1",
Expand All @@ -85,6 +88,7 @@
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^14.4.3",
"@types/jest": "^29.2.4",
"@types/json-schema": "^7.0.12",
"@types/lodash": "^4.14.176",
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
Expand Down
11 changes: 3 additions & 8 deletions src/blocks/ContentLayout/ContentLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,9 @@ function getTextWidth(size: ContentTextSize) {

export const ContentLayoutBlock = (props: ContentLayoutBlockProps) => {
const isMobile = useContext(MobileContext);
const {textContent, fileContent, properties: cardLayoutProperties = {size: 'l'}} = props;
const {
size = 'l',
background,
centered,
theme = 'default',
textWidth = 'm',
} = cardLayoutProperties;
const {textContent, fileContent} = props;
const propsSource = props.properties || props;
const {size = 'l', background, centered, theme = 'default', textWidth = 'm'} = propsSource;

const colSizes = useMemo(() => getTextWidth(textWidth), [textWidth]);

Expand Down
44 changes: 25 additions & 19 deletions src/blocks/ContentLayout/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,37 @@ import {
import {filteredArray} from '../../schema/validators/utils';
import {ContentBlock} from '../../sub-blocks/Content/schema';

const ContentLayoutBlockProperties = {
size: {
type: 'string',
enum: contentSizes,
},
background: ImageObjectProps,
centered: {
type: 'boolean',
},
theme: {
type: 'string',
enum: contentThemes,
},
textWidth: {
type: 'string',
enum: contentTextWidth,
},
};

export const ContentLayoutBlock = {
'content-layout-block': {
additionalProperties: false,
properties: {
...BlockBaseProps,
textContent: ContentBlock,
textContent: ContentBlock?.content,
fileContent: filteredArray(FileLinkProps),
properties: {
size: {
type: 'string',
enum: contentSizes,
},
background: ImageObjectProps,
centered: {
type: 'boolean',
},
theme: {
type: 'string',
enum: contentThemes,
},
textWidth: {
type: 'string',
enum: contentTextWidth,
},
},
/**
* @deprecated Use params on top level instead
*/
properties: ContentLayoutBlockProperties,
...ContentLayoutBlockProperties,
},
},
};
6 changes: 3 additions & 3 deletions src/blocks/ExtendedFeatures/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import {
BlockHeaderProps,
LinkProps,
containerSizesObject,
withTheme,
} from '../../schema/validators/common';
import {ImageProps} from '../../schema/validators/components';
import {filteredArray} from '../../schema/validators/utils';

export const ExtendedFeaturesItem = {
Expand All @@ -24,9 +26,7 @@ export const ExtendedFeaturesItem = {
enum: ['New', 'Preview'],
},
link: LinkProps,
icon: {
type: 'string',
},
icon: withTheme(ImageProps),
},
};

Expand Down
15 changes: 13 additions & 2 deletions src/blocks/FilterBlock/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,18 @@ export const FilterProps = {
...BlockBaseProps,
...AnimatableProps,
...BlockHeaderProps,
allTag: {oneOf: [{type: 'boolean'}, {type: 'string'}]},
allTag: {
oneOf: [
{
type: 'boolean',
optionName: 'auto',
},
{
type: 'string',
optionName: 'cutom',
},
],
},
colSizes: containerSizesObject,
tags: filteredArray(FilterTagProps),
items: filteredArray(FilterItemProps),
Expand All @@ -52,5 +63,5 @@ export const FilterProps = {
};

export const FilterBlock = {
'filterable-block': FilterProps,
'filter-block': FilterProps,
};
1 change: 1 addition & 0 deletions src/blocks/Header/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const HeaderProperties = {
description: {
type: 'string',
contentType: 'yfm',
inputType: 'textarea',
},
width: {
type: 'string',
Expand Down
4 changes: 3 additions & 1 deletion src/blocks/HeaderSlider/schema.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import _ from 'lodash';

import {HeaderProperties, SliderProps} from '../../schema/validators/blocks';
import {BlockBaseProps} from '../../schema/validators/common';

Expand All @@ -7,7 +9,7 @@ export const HeaderSliderBlock = {
required: ['items'],
properties: {
...BlockBaseProps,
...SliderProps,
..._.omit(SliderProps, ['loadable', 'children']),
items: {
type: 'array',
items: {
Expand Down
3 changes: 2 additions & 1 deletion src/blocks/Icons/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const IconsProps = {
size: {
type: 'string',
enum: ['s', 'm', 'l'],
default: 's',
},
items: {
type: 'array',
Expand All @@ -38,5 +39,5 @@ export const IconsProps = {
};

export const IconsBlock = {
'icon-block': IconsProps,
'icons-block': IconsProps,
};
3 changes: 2 additions & 1 deletion src/blocks/Media/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
ButtonBlock,
MediaProps,
mediaDirection,
withTheme,
} from '../../schema/validators/common';
import {ContentBase} from '../../sub-blocks/Content/schema';

Expand Down Expand Up @@ -52,7 +53,7 @@ export const MediaBlock = {
required: ['title', 'media'],
properties: {
...MediaBlockBaseProps,
media: Media,
media: withTheme(Media),
},
},
};
1 change: 1 addition & 0 deletions src/blocks/PromoFeaturesBlock/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const PromoFeaturesItem = {
text: {
type: 'string',
contentType: 'yfm',
inputType: 'textarea',
},
theme: {
enum: ['accent', 'accent-light', 'primary'],
Expand Down
9 changes: 4 additions & 5 deletions src/blocks/Slider/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,15 @@ const LoadableProps = {
properties: {
source: {
type: 'string',
enum: ['events', 'blog', 'services'],
// add loadable sources here if you use it in your project
// enum: ['my-loadable-source-1', 'my-loadable-source-1'],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems to me not very obvious how to add, can we leave an example?

Copy link
Contributor Author

@gorgeousvlad gorgeousvlad Jun 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it needs a story for slider, created a ticket for it

},
/**
* @deprecated
*/
minCount: {
type: 'number',
},
/**
* @deprecated Will be moved to params
*/
serviceId: {type: 'number'},
params: {
type: 'object',
patternProperties: {
Expand All @@ -34,6 +31,8 @@ const LoadableProps = {
},
},
},
// remove it in your custom validator schema if you use loadable
disabled: true,
};

const DisclaimerProps = {
Expand Down
14 changes: 12 additions & 2 deletions src/blocks/Table/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,18 @@ export const TableBlock = {
items: {
type: 'array',
items: {
type: ['string', 'number'],
contentType: 'text',
oneOf: [
{
type: 'string',
contentType: 'text',
optionName: 'text',
},
{
type: 'number',
contentType: 'text',
optionName: 'number',
},
],
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions src/components/BlockBase/BlockBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import './BlockBase.scss';
const b = block('block-base');

const BlockBase = (props: PropsWithChildren<BlockBaseProps & ClassNameProps>) => {
const {anchor, visible, children, className, resetPaddings, qa, index = 0} = props;
const {anchor, visible, children, className, resetPaddings, qa, type, index} = props;

return (
<Col
Expand All @@ -20,7 +20,7 @@ const BlockBase = (props: PropsWithChildren<BlockBaseProps & ClassNameProps>) =>
reset={true}
dataQa={qa}
>
<BlockDecoration id={index}>
<BlockDecoration type={type} index={index}>
{anchor && <Anchor id={anchor.url} className={b('anchor')} />}
{children}
</BlockDecoration>
Expand Down
Loading