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

Feature/#117 distribute button #148

Merged
merged 13 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/// <reference types="cypress" />

describe("distributeButton", () => {
beforeEach(() => {
cy.visit("http://localhost:5173/");
});

it("is visible", () => {
cy.get(".control-panel--top_general").should("be.visible");
cy.get('[data-cy="distribute-button"]').should("be.visible");
});

it("is clickable", () => {
cy.get('[data-cy="distribute-button"]').click();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,10 @@ describe("startStopSwitch", () => {
.should("have.attr", "aria-checked", "true");
});
});

it("has default off/false", () => {
cy.get('[data-cy="startStopSwitch-0"]')
.find('[role="switch"]')
.should("have.attr", "aria-checked", "false");
});
});
41 changes: 6 additions & 35 deletions Apps/frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions Apps/frontend/src/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,19 @@ nav {

&--waves {
position: absolute;
margin-top: 0.1vw;
inset: 0;
}
}

.control-panel {
&--top {
&_general {
grid-column: 2;
grid-column: 2/6;
grid-row: 1;
display: flex;
align-self: center;
justify-content: space-evenly;
justify-content: start;
}
}

Expand Down Expand Up @@ -264,4 +265,8 @@ nav {
&--drop-down {
background-image: url("./assets/mui_drop-down.svg");
}

&--distribute {
background-image: url("./assets/mui_distribute.svg");
}
}
1 change: 1 addition & 0 deletions Apps/frontend/src/assets/mui_distribute.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions Apps/frontend/src/components/DistributeOffsetButton.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<script>
import { NUM_CHANNELS } from "../const";
import { channelActivated, offsetAdjustment } from "../stores";

function calculateOffset() {
motschel123 marked this conversation as resolved.
Show resolved Hide resolved
// offset is calculated based on the number of channels between -1 and 1
return 2 / ($channelActivated.filter(Boolean).length + 1);
}
</script>

<button
class="icon-button mui-icon--distribute"
on:click={() => {
let baseOffset = calculateOffset();
let offsetY = 1 - baseOffset;
for (let index = 0; index < NUM_CHANNELS; index++) {
if ($channelActivated[index]) {
$offsetAdjustment[index] = offsetY;
offsetY -= baseOffset;
}
}
}}
data-cy="distribute-button"
/>
17 changes: 3 additions & 14 deletions Apps/frontend/src/components/Slider.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
<script>
export let onInput = (value) => {
console.error(`Missing implementation of Slider.onInput(${value})!`);
return value;
};

export let value = 1;
export let min = 0;
export let max = 10;
Expand All @@ -12,18 +7,12 @@
export let dataCy = undefined;
export let className = undefined;
export let calculateDisplayedValue = undefined;

export let onInput = () => {};
</script>

<div class={className} data-cy={dataCy}>
<input
{id}
type="range"
on:input={() => onInput(value)}
bind:value
{min}
{max}
{step}
/>
<input {id} type="range" bind:value on:input={onInput} {min} {max} {step} />
{#if calculateDisplayedValue !== undefined}
<span>{calculateDisplayedValue(value)}</span>
{/if}
Expand Down
25 changes: 0 additions & 25 deletions Apps/frontend/src/components/StartStopButton.svelte

This file was deleted.

17 changes: 17 additions & 0 deletions Apps/frontend/src/components/StartStopSwitch.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<script>
import Switch from "svelte-toggle";
import { LINE_COLORS_RGBA } from "../const.js";
import { channelActivated } from "../stores.js";
export let channel;

let color = LINE_COLORS_RGBA[channel];
</script>

<div class="control-panel--bottom_switch" data-cy="startStopSwitch-{channel}">
<Switch
hideLabel
small
bind:toggled={$channelActivated[channel]}
toggledColor={color}
/>
</div>
11 changes: 2 additions & 9 deletions Apps/frontend/src/components/ThicknessSwitch.svelte
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
<script>
import Switch from "svelte-toggle";
import { LINE_COLORS_RGBA } from "../const.js";
import { channelConfig } from "../stores.js";

export let onClick = (event) => {
console.error(`Missing implementation for thickness)!`);
};
import { thicknessAdjustment } from "../stores.js";

export let channel;
</script>
Expand All @@ -14,10 +10,7 @@
<Switch
hideLabel
small
bind:toggled={$channelConfig[channel].thickness}
on:click={() => {
onClick();
}}
bind:toggled={$thicknessAdjustment[channel]}
toggledColor={LINE_COLORS_RGBA[channel]}
/>
</div>
Loading