mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-14 20:20:30 +00:00
A couple of CSS tweaks
- Fix the "Run" button scrolling horizontally on small screens. - Make the "X" in the computer popup square. - Make the computer popup more fun.
This commit is contained in:
parent
504567292b
commit
82947a6e67
@ -88,7 +88,7 @@ class Window extends Component<WindowProps, WindowState> {
|
|||||||
|
|
||||||
const mount = element.getAttribute("data-mount");
|
const mount = element.getAttribute("data-mount");
|
||||||
const peripheral = element.getAttribute("data-peripheral");
|
const peripheral = element.getAttribute("data-peripheral");
|
||||||
render(<Click run={this.runExample(example, mount, peripheral)} />, element);
|
render(<Click run={this.runExample(example, mount, peripheral)} />, element.parentElement!!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,6 +98,7 @@ class Window extends Component<WindowProps, WindowState> {
|
|||||||
|
|
||||||
public render(_: WindowProps, { visible, example, exampleIdx }: WindowState): ComponentChild {
|
public render(_: WindowProps, { visible, example, exampleIdx }: WindowState): ComponentChild {
|
||||||
return visible ? <div class="example-window" style={`transform: translate(${this.left}px, ${this.top}px);`}>
|
return visible ? <div class="example-window" style={`transform: translate(${this.left}px, ${this.top}px);`}>
|
||||||
|
<div class="example-contents">
|
||||||
<div class="titlebar">
|
<div class="titlebar">
|
||||||
<div class="titlebar-drag" onMouseDown={this.onMouseDown} onTouchStart={this.onTouchDown} />
|
<div class="titlebar-drag" onMouseDown={this.onMouseDown} onTouchStart={this.onTouchDown} />
|
||||||
<button type="button" class="titlebar-close" onClick={this.close}>{"\u2715"}</button>
|
<button type="button" class="titlebar-close" onClick={this.close}>{"\u2715"}</button>
|
||||||
@ -107,6 +108,7 @@ class Window extends Component<WindowProps, WindowState> {
|
|||||||
...defaultFiles, ...example!.files,
|
...defaultFiles, ...example!.files,
|
||||||
}} peripherals={{ back: example!.peripheral }} />
|
}} peripherals={{ back: example!.peripheral }} />
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div> : <div class="example-window example-window-hidden" />;
|
</div> : <div class="example-window example-window-hidden" />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
// SPDX-FileCopyrightText: 2020 The CC: Tweaked Developers
|
/*
|
||||||
//
|
SPDX-FileCopyrightText: 2020 The CC: Tweaked Developers
|
||||||
// SPDX-License-Identifier: LicenseRef-CCPL
|
|
||||||
|
SPDX-License-Identifier: LicenseRef-CCPL
|
||||||
|
*/
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--nav-width: 250px;
|
--nav-width: 250px;
|
||||||
@ -29,7 +31,7 @@ table th {
|
|||||||
background-color: var(--background-2);
|
background-color: var(--background-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
pre.highlight {
|
div.lua-example {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,6 +51,24 @@ pre.highlight {
|
|||||||
top: 0px;
|
top: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.example-window-hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.example-contents {
|
||||||
|
animation: popup 0.3s cubic-bezier(.18,.89,.32,1.28);
|
||||||
|
transform-origin: center center;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes popup {
|
||||||
|
0% { scale: 0.5; }
|
||||||
|
100% { scale: 1; }
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.example-contents { animation: none; }
|
||||||
|
}
|
||||||
|
|
||||||
/* Behold, the most cursed CSS! copy-cat's resizing algorithm is a weird, in
|
/* Behold, the most cursed CSS! copy-cat's resizing algorithm is a weird, in
|
||||||
that it basically does "wrapper height - 40px" to determine the effective
|
that it basically does "wrapper height - 40px" to determine the effective
|
||||||
size. But the footer is actually 1em+6px high, so we need to do very weird
|
size. But the footer is actually 1em+6px high, so we need to do very weird
|
||||||
@ -62,10 +82,6 @@ pre.highlight {
|
|||||||
margin-top: calc((1em + 6px - 40px) / 2);
|
margin-top: calc((1em + 6px - 40px) / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
.example-window-hidden {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.titlebar {
|
.titlebar {
|
||||||
display: flex;
|
display: flex;
|
||||||
background: #dede6c;
|
background: #dede6c;
|
||||||
@ -84,6 +100,7 @@ pre.highlight {
|
|||||||
border-radius: 0px;
|
border-radius: 0px;
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
|
width: 30px; /* Same as titlebar height. */
|
||||||
}
|
}
|
||||||
|
|
||||||
.titlebar-close:hover {
|
.titlebar-close:hover {
|
||||||
|
@ -37,6 +37,12 @@ import { DataExport, WithExport } from "./components/WithExport.js";
|
|||||||
components: {
|
components: {
|
||||||
['mc-recipe']: noChildren(Recipe),
|
['mc-recipe']: noChildren(Recipe),
|
||||||
['mcrecipe']: noChildren(Recipe),
|
['mcrecipe']: noChildren(Recipe),
|
||||||
|
// Wrap example snippets in a <div class="lua-example">...</div>, so we can inject a
|
||||||
|
// Run button into them.
|
||||||
|
['pre']: (args: JSX.IntrinsicElements["pre"] & { "data-lua-kind"?: undefined }) => {
|
||||||
|
const element = <pre {...args} />;
|
||||||
|
return args["data-lua-kind"] ? <div className="lua-example">{element}</div> : element
|
||||||
|
}
|
||||||
} as any
|
} as any
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user