feat: implement feature flags
This commit is contained in:
parent
1a36871616
commit
e86d9bc04c
2 changed files with 31 additions and 5 deletions
|
@ -1,23 +1,35 @@
|
||||||
---
|
---
|
||||||
import Icon from "astro-iconify";
|
import Icon from "astro-iconify";
|
||||||
|
import { featureFlags, featureLabels } from "../utils/feature-flags";
|
||||||
export interface Props {
|
export interface Props {
|
||||||
toggle: string;
|
toggle: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const enabledSettings = Object.keys(featureFlags).filter(
|
||||||
|
(key) => featureFlags[key]
|
||||||
|
);
|
||||||
|
|
||||||
const { toggle } = Astro.props;
|
const { toggle } = Astro.props;
|
||||||
---
|
---
|
||||||
|
|
||||||
<form id="settings-form" hidden>
|
<form id="settings-form">
|
||||||
<div id="toolbar">
|
<div id="toolbar">
|
||||||
<h2>Settings</h2>
|
<h2>Settings</h2>
|
||||||
<label for={toggle}>
|
<label for={toggle}>
|
||||||
<Icon name="mdi:close" />
|
<Icon name="mdi:close" />
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
{
|
||||||
|
enabledSettings.map(
|
||||||
|
(settings) =>
|
||||||
|
settings !== "" && (
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<input type="checkbox" id="settings-1" name="settings-1" checked />
|
<input type="checkbox" id="settings-2" name="settings-2" />
|
||||||
<label for="settings-1">Option 1</label>
|
<label for="settings-2">{featureLabels[settings]}</label>
|
||||||
</div>
|
</div>
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|
14
src/utils/feature-flags.ts
Normal file
14
src/utils/feature-flags.ts
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
export enum Features {
|
||||||
|
"SendToEmail",
|
||||||
|
"HideImages",
|
||||||
|
}
|
||||||
|
|
||||||
|
export const featureLabels: Record<Features, string> = {
|
||||||
|
[Features.SendToEmail]: "Send to email",
|
||||||
|
[Features.HideImages]: "Hide images",
|
||||||
|
};
|
||||||
|
|
||||||
|
export const featureFlags: Record<Features, boolean> = {
|
||||||
|
[Features.SendToEmail]: false,
|
||||||
|
[Features.HideImages]: true,
|
||||||
|
};
|
Loading…
Reference in a new issue