Skip to content

Commit a4c6f3e

Browse files
committed
basic showing
1 parent 957aa64 commit a4c6f3e

File tree

2 files changed

+137
-19
lines changed

2 files changed

+137
-19
lines changed

ui/frontend/Header.tsx

+70-19
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,62 @@ interface HeaderProps {
178178
wasmAvailable: boolean;
179179
}
180180

181+
import { Manager, Target, Popper, Arrow } from 'react-popper';
182+
183+
const Header2 = () => (
184+
<div className="header2">
185+
<button>BUILD</button>
186+
<Manager>
187+
<Target>
188+
<button>...</button>
189+
</Target>
190+
<Popper className="popper" placement="bottom">
191+
<Arrow className="popper__arrow" />
192+
<div className="popper__content"><BuildMenu /></div>
193+
</Popper>
194+
</Manager>
195+
</div>
196+
);
197+
198+
const BuildMenu = () => (
199+
<div className="build-options">
200+
<h1 className="build-options__title">What do you want to do?</h1>
201+
<BuildOption
202+
name="Build"
203+
description="No bells and whistles, regular build coming right up :D"
204+
/>
205+
<BuildOption
206+
name="ASM"
207+
description="Build and show the resulting assembly code."
208+
/>
209+
<BuildOption
210+
name="LLVM IR"
211+
description="Build and show the resulting LLVM IR, LLVM's intermediate representation."
212+
/>
213+
<BuildOption
214+
name="MIR"
215+
description="Build and show the resulting MIR, Rust's intermediate representation."
216+
/>
217+
<BuildOption
218+
name="WASM"
219+
description="Build a WebAssembly module for web browsers, in the .WAT textual representation.
220+
Note: WASM currently requires using the Nightly channel, selecting this option will switch to Nightly."
221+
/>
222+
</div>
223+
);
224+
225+
const BuildOption = ({name, description}) => (
226+
<button className="build-option">
227+
<span className="build-option__name">{name}</span>
228+
<span className="build-option__description">{description}</span>
229+
</button>
230+
);
231+
181232
const mapStateToProps = (state: State) => {
182-
const { configuration: { channel, mode } } = state;
233+
const {configuration: {channel, mode } } = state;
183234

184235
return {
185-
channel,
236+
channel,
186237
mode,
187238
crateType: getCrateType(state),
188239
tests: runAsTest(state),
@@ -195,22 +246,22 @@ const mapStateToProps = (state: State) => {
195246
};
196247

197248
const mapDispatchToProps = ({
198-
changeChannel,
199-
changeMode,
200-
clippy: performClippy,
201-
compileToAssembly: performCompileToAssembly,
202-
compileToLLVM: performCompileToLLVM,
203-
compileToMir: performCompileToMir,
204-
compileToWasm: performCompileToWasm,
205-
execute: performExecute,
206-
format: performFormat,
207-
gistSave: performGistSave,
208-
toggleConfiguration,
209-
});
249+
changeChannel,
250+
changeMode,
251+
clippy: performClippy,
252+
compileToAssembly: performCompileToAssembly,
253+
compileToLLVM: performCompileToLLVM,
254+
compileToMir: performCompileToMir,
255+
compileToWasm: performCompileToWasm,
256+
execute: performExecute,
257+
format: performFormat,
258+
gistSave: performGistSave,
259+
toggleConfiguration,
260+
});
210261

211-
const ConnectedHeader = connect(
212-
mapStateToProps,
213-
mapDispatchToProps,
214-
)(Header);
262+
const ConnectedHeader = connect(
263+
mapStateToProps,
264+
mapDispatchToProps,
265+
)(Header2);
215266

216-
export default ConnectedHeader;
267+
export default ConnectedHeader;

ui/frontend/index.scss

+67
Original file line numberDiff line numberDiff line change
@@ -525,3 +525,70 @@ $PHI: 2.61803398875;
525525
opacity: 1;
526526
}
527527
}
528+
529+
.header2 {
530+
display: flex;
531+
}
532+
533+
.popper {
534+
z-index: 100;
535+
536+
$fg-color: #222;
537+
$bg-color: white;
538+
$arrow-size: 10px;
539+
540+
&__arrow {
541+
position: absolute;
542+
margin: $arrow-size;
543+
border: $arrow-size solid transparent;
544+
}
545+
546+
&[data-placement^="bottom"] &__arrow {
547+
margin-top: 0;
548+
border-top-width: 0;
549+
border-bottom-color: $bg-color;
550+
}
551+
552+
&__content {
553+
background: $bg-color;
554+
color: $fg-color;
555+
border-radius: 2px;
556+
box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
557+
margin: $arrow-size;
558+
}
559+
}
560+
561+
.build-options {
562+
width: 20em;
563+
564+
&__title {
565+
font-size: medium;
566+
padding: 0.5em;
567+
margin: 0;
568+
border-bottom: 1px solid #CCC;
569+
}
570+
}
571+
572+
.build-option {
573+
display: flex;
574+
flex-direction: column;
575+
padding: 0.5em;
576+
577+
// Button reset
578+
border: none;
579+
text-align: inherit;
580+
width: inherit;
581+
582+
&:hover {
583+
background-color: aliceblue;
584+
}
585+
586+
&__name {
587+
font-weight: bold;
588+
margin-bottom: 0.25em;
589+
}
590+
591+
&__description {
592+
font-size: 90%;
593+
}
594+
}

0 commit comments

Comments
 (0)