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

fix: scrolling in devtools #121

Merged
merged 2 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions packages/devtools/src/Devtools.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ const abbyMock = {
"flag-1": true,
"flag-2": false,
},
remoteConfig: {
"config-1": "string-value",
"config-2": 42,
"config-3": {type: "object/json"}
},
tests: {
"test-1": { selectedVariant: "A", variants: ["A", "B"] },
"test-2": { selectedVariant: "B", variants: ["A", "B"] },
Expand Down
124 changes: 76 additions & 48 deletions packages/devtools/src/Devtools.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -93,61 +93,63 @@
></small
>
<hr />
<h2>Flags:</h2>
{#each Object.entries(flags) as [flagName, flagValue]}
<Switch
id={flagName}
label={flagName}
checked={flagValue}
onChange={(newValue) => {
window.postMessage({ type: "abby:update-flag", flagName, newValue }, "*");
abby.updateFlag(flagName, newValue);
}}
/>
{/each}
<hr />
<h2>Remote Config:</h2>
{#each Object.entries(remoteConfig) as [remoteConfigName, remoteConfigValue]}
{#if typeof remoteConfigValue === "string" || typeof remoteConfigValue === "number"}
<Input
id={remoteConfigName}
label={remoteConfigName}
type={typeof remoteConfigValue === "string" ? "text" : "number"}
value={remoteConfigValue}
<div class="content">
<h2>Flags:</h2>
{#each Object.entries(flags) as [flagName, flagValue]}
<Switch
id={flagName}
label={flagName}
checked={flagValue}
onChange={(newValue) => {
window.postMessage({ type: "abby:update-flag", remoteConfigName, newValue }, "*");
abby.updateRemoteConfig(remoteConfigName, newValue);
window.postMessage({ type: "abby:update-flag", flagName, newValue }, "*");
abby.updateFlag(flagName, newValue);
}}
/>
{:else if typeof remoteConfigValue === "object"}
<div style="display: flex; flex-direction: column; margin: 10px 0;">
<p style="margin-bottom: 5px;">{remoteConfigName}</p>
<Modal
{/each}
<hr />
<h2>Remote Config:</h2>
{#each Object.entries(remoteConfig) as [remoteConfigName, remoteConfigValue]}
{#if typeof remoteConfigValue === "string" || typeof remoteConfigValue === "number"}
<Input
id={remoteConfigName}
label={remoteConfigName}
type={typeof remoteConfigValue === "string" ? "text" : "number"}
value={remoteConfigValue}
onChange={(newValue) => {
window.postMessage({ type: "abby:update-flag", remoteConfigName, newValue }, "*");
abby.updateRemoteConfig(remoteConfigName, newValue);
}}
/>
</div>
{/if}
{/each}
<hr />
<h2>A/B Tests:</h2>
{#each Object.entries(tests) as [testName, { selectedVariant, variants }]}
<Select
label={testName}
value={selectedVariant}
options={variants.map((v) => ({
label: v,
value: v,
}))}
onChange={(newValue) => {
window.postMessage({ type: "abby:select-variant", testName, newValue }, "*");
abby.updateLocalVariant(testName, newValue);
}}
/>
{/each}
{:else if typeof remoteConfigValue === "object"}
<div style="display: flex; flex-direction: column; margin: 10px 0;">
<p style="margin-bottom: 5px;">{remoteConfigName}</p>
<Modal
value={remoteConfigValue}
onChange={(newValue) => {
window.postMessage({ type: "abby:update-flag", remoteConfigName, newValue }, "*");
abby.updateRemoteConfig(remoteConfigName, newValue);
}}
/>
</div>
{/if}
{/each}
<hr />
<h2>A/B Tests:</h2>
{#each Object.entries(tests) as [testName, { selectedVariant, variants }]}
<Select
label={testName}
value={selectedVariant}
options={variants.map((v) => ({
label: v,
value: v,
}))}
onChange={(newValue) => {
window.postMessage({ type: "abby:select-variant", testName, newValue }, "*");
abby.updateLocalVariant(testName, newValue);
}}
/>
{/each}
</div>
</div>
{:else}
<button
Expand Down Expand Up @@ -188,7 +190,9 @@
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
box-shadow:
0 10px 15px -3px rgb(0 0 0 / 0.1),
0 4px 6px -4px rgb(0 0 0 / 0.1);
}

#abby-devtools {
Expand All @@ -201,14 +205,17 @@
left: var(--left);
top: var(--top);
background: #121929;
padding: 15px 10px;
padding-inline: 10px;
padding-top: 10px;
z-index: 9999;
border-radius: 6px;
border: 2px solid var(--pink);
font-size: 14px;
color: hsl(213 31% 91%);
min-width: 300px;
display: flex;
flex-direction: column;
max-height: calc(100vh - 3rem);

.logo {
font-family: "Martian Mono", inherit;
Expand All @@ -235,6 +242,27 @@
cursor: pointer;
}
}
.content {
margin-top: -1rem;
padding-top: 1rem;
padding-bottom: calc(1rem - 10px);
overflow-y: auto;
&::-webkit-scrollbar {
width: 10px;
}
&::-webkit-scrollbar-track {
background-color: transparent;
}
&::-webkit-scrollbar-thumb {
background-color: rgba(255, 255, 255, 0.4);
border: 6px solid transparent;
border-right-width: 0px;
background-clip: content-box;
&:hover {
background-color: rgba(255, 255, 255, 0.6);
}
}
}
h1,
h2 {
all: unset;
Expand Down
Loading