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 invalid regex value and update components based on changes in shared-ui project #26

Merged
merged 2 commits into from
May 11, 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
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,7 @@
import { downloadUserThemeJson } from '$lib/theme';
import type { AppStore, ColorPickerStore, ThemeEditorStore, UserThemeImported } from '$lib/types';
import { getThemeEditorSlotExampleCode } from '$lib/util';
import {
ColorParser,
createEmptyColorPalette,
type ComponentColor,
type CssColor,
type ThemeColor,
} from '@a-luna/shared-ui';
import { getColorSchemesForAllColorFormats } from '@a-luna/shared-ui/color/schemes';
import { createEmptyColorPalette, type ComponentColor, type CssColor, type ThemeColor } from '@a-luna/shared-ui';
import { createEventDispatcher } from 'svelte';
import { HighlightSvelte } from 'svelte-highlight';
import type { Readable } from 'svelte/store';
Expand Down Expand Up @@ -151,13 +144,13 @@
app: $app,
});
}
$: {
const result = ColorParser.parse('oklch(87.78% 0.205 147.55 / 75%)');
if (result.success) {
const schemeSet = getColorSchemesForAllColorFormats(result.value);
console.log({ schemeSet });
}
}
// $: {
// const result = ColorParser.parse('oklch(87.78% 0.205 147.55 / 75%)');
// if (result.success) {
// const schemeSet = getColorSchemesForAllColorFormats(result.value);
// console.log({ schemeSet });
// }
// }

$: if (typeof window !== 'undefined' && !editorStateInitialized) {
themeEditor = createThemeEditorStore();
Expand All @@ -178,7 +171,7 @@
dispatch('uiColorChanged', { uiColor: userTheme.uiColor });
}

function handleUiColorChanged(e: CustomEvent<null>) {
function handleUiColorChanged(_: CustomEvent<null>) {
dispatch('uiColorChanged', { uiColor: $themeEditor.userTheme.uiColor });
}

Expand Down Expand Up @@ -297,7 +290,7 @@
--button-background-color-hover: var(--hover-bg-color);
--button-background-color-active: var(--active-bg-color);
--button-background-color-disabled: var(--disabled-bg-color);
--button-border: 1px solid var(--border-color);
--button-border: 2px solid var(--border-color);

display: flex;
flex-flow: column nowrap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<div class="bg-color-selector">
Background Color
<BgColorSelector bind:value={bgColorHex} disabled={useCustomColor} />
<UseCustomColorCheckbox {componentColor} bind:checked={useCustomColor} />
<UseCustomColorCheckbox bind:checked={useCustomColor} />
{#if useCustomColor}
<InputTextBox
bind:this={customColorTextBox}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<script lang="ts">
import { Checkbox, type ComponentColor } from '@a-luna/shared-ui';
import { Checkbox } from '@a-luna/shared-ui';

export let checked: boolean;
export let componentColor: ComponentColor;
</script>

<Checkbox id={'use-custom-color-checkbox'} bind:checked>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
$: tooltip = disabled ? 'Select a palette from the list above' : 'Add color to the selected palette';
</script>

<ThemeButton {tooltip} {disabled} gridStyle={style} on:click>
<ThemeButton {tooltip} {disabled} gridStyle={style} iconWidth={'16px'} on:click>
<svelte:fragment slot="icon">
<BasicIconRenderer icon={'plus'} />
</svelte:fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
<SelectedColor />
<div class="button-list">
<SetColorPickerButton
style={'grid-column: 2 / span 1; grid-row: 4 / span 1;'}
on:click={() => dispatch('setColorPickerValue', { color: $themeEditor.selectedColor.color })}
disabled={disableControls || !$themeEditor.colorSelected}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
gridStyle={style}
tooltip={'Set Color Picker Value to Selected Color'}
{disabled}
iconWidth={'13px'}
iconWidth={'16px'}
wrapperWidth={'32px'}
on:click
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
export let disabled = false;
</script>

<ThemeButton tooltip={'Edit Theme Settings'} {disabled} iconWidth={'21px'} on:click>
<ThemeButton tooltip={'Edit Theme Settings'} {disabled} iconWidth={'16px'} on:click>
<svelte:fragment slot="icon">
<BasicIconRenderer icon={'gear'} width={'21px'} />
<BasicIconRenderer icon={'gear'} width={'16px'} />
</svelte:fragment>
</ThemeButton>
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
export let disabled = false;
</script>

<ThemeButton tooltip={'Export User Theme'} {disabled} iconWidth={'25px'} on:click>
<ThemeButton tooltip={'Export User Theme'} {disabled} iconWidth={'18px'} on:click>
<svelte:fragment slot="icon">
<BasicIconRenderer icon={'export'} width={'25px'} />
<BasicIconRenderer icon={'export'} width={'18px'} />
</svelte:fragment>
</ThemeButton>
4 changes: 1 addition & 3 deletions packages/svelte-color-tools/src/lib/theme/util.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import type { ThemeColorShallowCopy, UserThemeImported } from '$lib/types';
import type { ColorFormat, CssColor, ThemeColor } from '@a-luna/shared-ui';

// TODO: Investigate error raised when updating/adding new color to palette which sais that the PROP_NAME_REGEX is an invalid regular expression.

export const CAMEL_CASE_REGEX = /^[a-z](?=.*[A-Z])[A-Za-z]*[^[-`]$/;
export const PROP_NAME_REGEX = /^[a-z]+$|^[a-z](?=.*[A-Z])[A-Za-z]*[^\[-`]$/;
export const PROP_NAME_REGEX = /^[a-z]+$|^[a-z](?=.*[A-Z])[A-Za-z]*[^[-`]$/;
export const CSS_VAR_NAME_REGEX = /^--[A-Za-z][0-9A-Za-z-]*$/;

export function getCssValueForThemeColor(color: ThemeColor, colorFormat: ColorFormat): string {
Expand Down