简体   繁体   English

渲染反应组件预览

[英]Render react component preview

Today I have the following problem: I have a form to set the title, background color, button background and text color, etc, of a component, and I want to render a preview of that component while the user is changing the settings. 今天我有以下问题:我有一个表单来设置组件的标题,背景颜色,按钮背景和文本颜色等,我想在用户更改设置时呈现该组件的预览。

The thing is, I want to render a "preview" of the component, suppose in an small viewport (or do like a zoom-out) next to the form, so the user can preview the component while he (or she) is changing the style of the component. 问题是,我想渲染组件的“预览”,假设在窗体旁边的一个小视口中(或者像缩小一样),这样用户可以在他(或她)改变时预览组件组件的风格。 The readable of the texts is not important, the only thing I want to do is to give an idea to the user of how the component will change once he save the new settings. 文本的可读性并不重要,我唯一想做的就是在保存新设置后向用户说明组件如何更改。

在此输入图像描述

Something like that is the form, and I want to render a preview of the component (zoomed-out) next to the form. 这样的形式就是表单,我想在表单旁边呈现组件的预览(缩小)。

Any ideas? 有任何想法吗?

Thanks. 谢谢。

Why not use css transform scale? 为什么不使用css转换规模?

Roughly like this 粗略喜欢这个

const Test = styled.div`
  ${props => props.preview && `
    transform: scale(0.5);
  `};
`;

https://codesandbox.io/s/o5w0588ymq https://codesandbox.io/s/o5w0588ymq

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM