Skip to content
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

Editor mobile devices preview mode #437

Merged
merged 29 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
83b9e35
feat: first working ver
gorgeousvlad Jul 5, 2023
8cbae2e
fix: errors
gorgeousvlad Jul 5, 2023
c7debc8
feat: iframe separate window first ver
gorgeousvlad Jul 7, 2023
9a6dd68
feat: refactor editor device emulation
gorgeousvlad Jul 11, 2023
09e9a99
fix: linter
gorgeousvlad Jul 11, 2023
3c44c31
feat: add iframe buuild pt.1
gorgeousvlad Jul 16, 2023
6a93cd6
fix: remove gulp iframe build
gorgeousvlad Jul 16, 2023
d469356
fix: remove extra babel preset deps
gorgeousvlad Jul 16, 2023
6974d85
fix: update tablet icon
gorgeousvlad Jul 17, 2023
76347af
fix: refactor iframe build
gorgeousvlad Jul 17, 2023
a2ed1cd
fix: iframe bundle import
gorgeousvlad Jul 17, 2023
240c8ea
fix: remove brovserify-css
gorgeousvlad Jul 17, 2023
9a7bb20
fix: remove useDocumentCSS
gorgeousvlad Jul 17, 2023
e9405f0
fix: remove comment
gorgeousvlad Jul 17, 2023
5ec9342
fix: remove iframe bundle
gorgeousvlad Jul 17, 2023
9a78288
fix: dev build
gorgeousvlad Jul 17, 2023
06ce474
feat: add iframe to dev build
gorgeousvlad Jul 18, 2023
1fdcf01
feat: add ts alias for widget in build
gorgeousvlad Jul 18, 2023
6fdc66b
feat: rename iframe to widget
gorgeousvlad Jul 18, 2023
3fb0dd0
fix: add widget to package.json exports
gorgeousvlad Jul 18, 2023
b5a8c45
feat: pass provider prop to widget
gorgeousvlad Jul 19, 2023
1f43961
fix: remove condition form iframe window
gorgeousvlad Jul 19, 2023
78af921
feat: move content transformation to editor
gorgeousvlad Jul 19, 2023
ec62c62
fix: rename adding widget method
gorgeousvlad Jul 19, 2023
1810c50
fix: widget style ordering
gorgeousvlad Jul 19, 2023
b06ed61
fix: trying to fix preview build
gorgeousvlad Jul 19, 2023
e3925aa
feat: add emulation custom props passing
gorgeousvlad Jul 19, 2023
4609ffc
fix: remove comment and fix readme
gorgeousvlad Jul 19, 2023
4b24ce9
fix: code review
gorgeousvlad Jul 20, 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ node_modules
/configure
/styles/**/*.css
/coverage
/widget

*.tgz
.env
Expand Down
18 changes: 17 additions & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
const {join} = require('path');
const {join, resolve} = require('path');
const WebpackShellPlugin = require('webpack-shell-plugin');

const customAlias = {
widget: resolve(__dirname, '../widget'),
};

const config = {
stories: ['../src/**/*.stories.@(ts|tsx)'],
Expand Down Expand Up @@ -31,6 +36,17 @@ const config = {
// to turn fileName in context.parameters into path form number in production bundle
storybookBaseConfig.optimization.moduleIds = 'named';

storybookBaseConfig.plugins.push(
new WebpackShellPlugin({
onBuildStart: ['npm run build:widget'],
}),
);

storybookBaseConfig.resolve.alias = {
...(storybookBaseConfig.resolve?.alias || {}),
...customAlias,
};

return storybookBaseConfig;
},
};
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,17 +374,15 @@ Editor provides user interface for page content management with realtime preview
How to use:

```tsx
import {PageConstructor} from '@gravity-ui/page-constructor';
import {Editor} from '@gravity-ui/page-constructor/editor';

interface MyAppEditorProps {
initialContent: PageContent;
transformContent: ContentTransformer;
onChange: (content: PageContent) => void;
}

export const MyAppEditor = ({initialContent, onChange}: MyAppEditorProps) => (
<Editor onChange={onChange} content={initialContent}>
{(props) => <PageConstructor {...props} />}
</Editor>
export const MyAppEditor = ({initialContent, onChange, transformContent}: MyAppEditorProps) => (
<Editor content={initialContent} onChange={onChange} transformContent={transformContent} />
);
```
6 changes: 5 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const path = require('path');
const {task, src, dest, series, parallel} = require('gulp');
const sass = require('gulp-dart-sass');
const replace = require('gulp-replace');
const alias = require('gulp-ts-alias');
const ts = require('gulp-typescript');
const rimraf = require('rimraf');

Expand Down Expand Up @@ -31,13 +32,15 @@ function compileTs(modules = false) {
'!src/**/__tests__/**/*',
'!src/server.ts',
'!src/configure.ts',
'!src/widget/**/*',
'!test-utils/**/*',
])
.pipe(
replace(/import '.+\.scss';/g, (match) =>
modules ? match.replace('.scss', '.css') : '',
),
)
.pipe(alias(tsProject.config))
.pipe(tsProject())
.pipe(dest(path.resolve(BUILD_CLIENT_DIR, modules ? ESM_DIR : CJS_DIR)));
}
Expand All @@ -58,6 +61,7 @@ task('copy-js-declarations', () => {
'!src/**/__stories__/**/*.d.ts',
'!src/**/__tests__/**/*.d.ts',
'!test-utils/**/*.d.ts',
'!src/widget/**/*',
])
.pipe(dest(path.resolve(BUILD_CLIENT_DIR, ESM_DIR)))
.pipe(dest(path.resolve(BUILD_CLIENT_DIR, CJS_DIR)));
Expand All @@ -74,7 +78,7 @@ task('styles-global', () => {
});

task('styles-components', () => {
return src([`src/**/*.scss`, `!src/**/__stories__/**/*.scss`])
return src([`src/**/*.scss`, `!src/**/__stories__/**/*.scss`, '!src/widget/**/*.scss'])
.pipe(sass().on('error', sass.logError))
.pipe(dest(path.resolve(BUILD_CLIENT_DIR, ESM_DIR)))
.pipe(dest(path.resolve(BUILD_CLIENT_DIR, CJS_DIR)));
Expand Down
Loading
Loading