From ef011a6b73fdc0486477a42d267c9d4102dc151a Mon Sep 17 00:00:00 2001 From: arkin0x Date: Fri, 13 Oct 2023 10:30:54 -0500 Subject: [PATCH] problem: problem tracker styles need to be improved problem: navigation is missing key links --- src/components/objects/Problem.svelte | 87 +++++++++++++++++++++++---- src/lib/helpers/ProblemDepthColor.ts | 31 ++++++++++ src/routes/Header.svelte | 4 +- src/routes/styles.css | 4 ++ 4 files changed, 113 insertions(+), 13 deletions(-) create mode 100644 src/lib/helpers/ProblemDepthColor.ts diff --git a/src/components/objects/Problem.svelte b/src/components/objects/Problem.svelte index b0ec1b4..2b845c8 100644 --- a/src/components/objects/Problem.svelte +++ b/src/components/objects/Problem.svelte @@ -1,21 +1,26 @@ + export let problem:Problem; + export let depth:number; + + $: depthColor = getDepthColor(depth) + + let openState: boolean + $: focusProblem = openState ? "problem focus-problem" : "problem" - + + -
{problem.Title}
- {#if problem.Summary}
{problem.Summary}
{/if} +

{problem.Title}

+ {#if problem.Summary}
{problem.Summary}
{/if}
- {#if problem.FullText}

{problem.FullText}

{/if} + {#if problem.FullText}

{problem.FullText}

{/if}
{#if problem.Children} @@ -24,4 +29,62 @@ $: border = depth > 0 ? "dotted purple" : "dotted purple" {/if} {/each} -{/if} \ No newline at end of file +{/if} + + diff --git a/src/lib/helpers/ProblemDepthColor.ts b/src/lib/helpers/ProblemDepthColor.ts new file mode 100644 index 0000000..5b6ae7d --- /dev/null +++ b/src/lib/helpers/ProblemDepthColor.ts @@ -0,0 +1,31 @@ +const color = [82, 255, 255] // starting color for problem border +const colorIncrement = 70 + +// write a function where the color depends on the depth according to this formula: +// the initial color is rgb(82, 255, 255) +// as the depth increases, g is decremented by 0x0F until it reaches a minimum of 82 +// then r is decremented by 0x0F until it reaches a maximum of 255 +// then b is decremented by 0x0F until it reaches a minimum of 82 +export const getDepthColor = (depth: number): string => { + let [r, g, b] = color; + + // decrement g until it reaches a minimum of 82 + while (depth > 0 && g > 82) { + g -= colorIncrement; + depth--; + } + + // decrement r until it reaches a maximum of 255 + while (depth > 0 && r < 255) { + r += colorIncrement; + depth--; + } + + // decrement b until it reaches a minimum of 82 + while (depth > 0 && b > 82) { + b -= colorIncrement; + depth--; + } + + return `rgb(${r}, ${g}, ${b})`; +} \ No newline at end of file diff --git a/src/routes/Header.svelte b/src/routes/Header.svelte index c7e2573..2dd5aca 100644 --- a/src/routes/Header.svelte +++ b/src/routes/Header.svelte @@ -46,6 +46,7 @@ + @@ -109,9 +110,10 @@ + - + diff --git a/src/routes/styles.css b/src/routes/styles.css index beb03b6..c2b441c 100644 --- a/src/routes/styles.css +++ b/src/routes/styles.css @@ -7,3 +7,7 @@ width: 100%; height: 100%; } + +html { + overflow-x: hidden; +} \ No newline at end of file