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

Add resizable editor/layout to playground #2296

Merged
merged 4 commits into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
68 changes: 54 additions & 14 deletions docs/_asset/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,6 @@ pre code,
background-color: #fafafa !important; /* Color from one-light */
}

.frame-body-box-fixed-height {
height: 20rem;
overflow-y: auto;
}

.frame-body-box {
padding: calc(1em + 1ex);
}
Expand Down Expand Up @@ -762,10 +757,21 @@ button.success {
mask-image: paint(squircle);
--squircle-radius: 10px;
border-radius: 10px;

display: flex;
flex-direction: column;
overflow: auto;

min-height: 10rem;
height: 24rem;
Comment on lines +767 to +768
Copy link
Contributor Author

Choose a reason for hiding this comment

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

these 2 can now be more easily adjusted to define the initial height of the panels

resize: vertical;
}

.frame-tab-bar {
flex-shrink: 0;
display: flex;
flex-direction: row;
align-items: stretch;
margin-block-start: calc(1em + 1ex);
list-style-type: none;
margin: 0;
Expand All @@ -776,10 +782,6 @@ button.success {
.frame-tab-bar-scroll {
overflow-x: auto;
overflow-y: hidden;
flex: 1;
flex-direction: row;
align-items: stretch;
flex-grow: 1;
mask-image: linear-gradient(
to right,
hsl(0deg 0% 100% / 30%),
Expand All @@ -789,11 +791,54 @@ button.success {
);
}

.react-tabs__tab-panel {
}

.react-tabs__tab-panel--selected {
flex-grow: 1;
display: flex;
flex-direction: column;
overflow: hidden;
}

/* Preview / Options */
.react-tabs__tab-panel--selected.tab-panel-scrollable {
overflow: auto;
}

.frame-body {
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
}

.react-tabs__tab-panel--selected > .frame-body {
flex-grow: 1;
display: flex;
flex-direction: column;
}
Copy link
Member

Choose a reason for hiding this comment

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

This selector applies to the options, making them rather big

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yes, this is because margin collapsing only applies to block and not flex

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed, also made them slightly smaller, will probably be better for introducing new options

CleanShot 2023-05-10 at 19 14 44@2x


.react-tabs__tab-panel--selected:not(.tab-panel-scrollable) > .frame-body {
overflow: hidden;
}

.frame-body > div,
Copy link
Member

Choose a reason for hiding this comment

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

This selector applies to the default “Box” (padding: 1rem; background-color: violet;) in the example, making it fill the available width. Is that intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean the available height?

Not intentional, fixed with better CSS scoping: .frame-body > .playground-editor-code-mirror

.frame-body > pre {
flex-grow: 1;
display: flex;
flex-direction: column;
overflow: hidden;
}

.frame-body > div > div.cm-editor {
flex-grow: 1;
overflow: hidden;
}

.frame-body > pre > code {
overflow-x: auto;
overflow-y: auto;
}

.frame-tab-bar + pre {
margin-block-start: 0;
}
Expand Down Expand Up @@ -923,11 +968,6 @@ button.success {
font-size: 1rem;
}

.ͼ1 .cm-scroller,
.ͼ1 .cm-content {
min-height: 20rem;
}

.ͼo {
border-bottom-left-radius: 2px;
border-bottom-right-radius: 2px;
Expand Down
18 changes: 9 additions & 9 deletions docs/_component/editor.client.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export function Editor({children}) {
</Tab>
</TabList>
<TabPanel>
<div className="frame-body frame-body-box-fixed-height">
<div className="frame-body">
<noscript>
<pre>
<code className="hljs language-md">
Expand All @@ -161,8 +161,8 @@ export function Editor({children}) {
/>
</div>
</TabPanel>
<TabPanel>
<form className="frame-body frame-body-box frame-body-box-fixed-height">
<TabPanel className="tab-panel-scrollable">
<form className="frame-body frame-body-box">
<label>
<input
checked={state.gfm}
Expand Down Expand Up @@ -238,16 +238,16 @@ export function Editor({children}) {
})}
</TabList>

<TabPanel>
<TabPanel className="tab-panel-scrollable">
<noscript>Enable JavaScript for the rendered result.</noscript>
<div className="frame-body frame-body-box-fixed-height frame-body-box">
<div className="frame-body frame-body-box">
<ErrorBoundary FallbackComponent={ErrorFallback}>
{state.file && state.file.result ? <Preview /> : null}
</ErrorBoundary>
</div>
</TabPanel>
<TabPanel>
<div className="frame-body frame-body-box-fixed-height">
<div className="frame-body">
{state.file ? (
stats.fatal ? (
<pre>
Expand All @@ -267,7 +267,7 @@ export function Editor({children}) {
</div>
</TabPanel>
<TabPanel>
<div className="frame-body frame-body-box-fixed-height">
<div className="frame-body">
{state.file && state.file.data.mdast ? (
<pre>
<code className="hljs language-js">
Expand All @@ -284,7 +284,7 @@ export function Editor({children}) {
</div>
</TabPanel>
<TabPanel>
<div className="frame-body frame-body-box-fixed-height">
<div className="frame-body">
{state.file && state.file.data.hast ? (
<pre>
<code className="hljs language-js">
Expand All @@ -301,7 +301,7 @@ export function Editor({children}) {
</div>
</TabPanel>
<TabPanel>
<div className="frame-body frame-body-box-fixed-height">
<div className="frame-body">
{state.file && state.file.data.esast ? (
<pre>
<code className="hljs language-js">
Expand Down