Skip to content

Commit

Permalink
chore(prettier): actually apply svelte plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
metonym committed Mar 31, 2024
1 parent 4635a0f commit ae81421
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 12 deletions.
8 changes: 6 additions & 2 deletions demo/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<ul>
<li><a href="/Simple">Simple</a></li>
<li><a href="/TwoWayBinding">Two-way binding</a></li>
<li><a href="/KitchenSink">Kitchen sink</a></li>
<li>
<a href="/TwoWayBinding">Two-way binding</a>
</li>
<li>
<a href="/KitchenSink">Kitchen sink</a>
</li>
</ul>

<style>
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"package": "svelte-package",
"test": "vitest",
"check": "svelte-check --tsconfig ./tsconfig.json",
"format": "prettier --ignore-path .gitignore --write ."
"format": "prettier --write ."
},
"peerDependencies": {
"svelte": "^3.51 || ^4"
Expand Down Expand Up @@ -59,5 +59,10 @@
],
"files": [
"dist"
]
],
"prettier": {
"plugins": [
"prettier-plugin-svelte"
]
}
}
17 changes: 13 additions & 4 deletions src/BarChartRace.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
const value = writable(currentValue ?? -1);
const valuesByKey = writable({});
const range: BarChartRaceContext["range"] = writable([]);
const chartOptions = writable({ ...DEFAULT_OPTIONS, ...options });
const chartOptions = writable({
...DEFAULT_OPTIONS,
...options,
});
const context: BarChartRaceContext = {
value,
valuesByKey,
Expand All @@ -55,7 +58,10 @@
$: valuesByKey.set(
data
.flatMap((datum) =>
datum.values.map((values) => ({ ...datum, ...values }))
datum.values.map((values) => ({
...datum,
...values,
})),
)
.reduce((values, value) => {
const currentKey = value[options.key];
Expand All @@ -65,13 +71,16 @@
: [value];
return values;
}, {})
}, {}),
);
$: range.set(Object.keys($valuesByKey).map((_value) => Number(_value)));
$: if ($value === -1) value.set($range[0]);
$: value.set(currentValue == null ? $range[0] : currentValue);
$: currentValue = $value;
$: chartOptions.set({ ...DEFAULT_OPTIONS, ...options });
$: chartOptions.set({
...DEFAULT_OPTIONS,
...options,
});
let isPlaying = false;
let timer: NodeJS.Timeout;
Expand Down
3 changes: 2 additions & 1 deletion src/Chart.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
*/
export let animate: FlipParams = {};
const { value, valuesByKey, chartOptions }: BarChartRaceContext = getContext("BarChartRace");
const { value, valuesByKey, chartOptions }: BarChartRaceContext =
getContext("BarChartRace");
</script>

<ol style:padding="var(--chart-padding, 0)">
Expand Down
3 changes: 2 additions & 1 deletion src/Slider.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
/** Specify the slider label text. */
export let labelText: any = "";
const { value, range, setValue }: BarChartRaceContext = getContext("BarChartRace");
const { value, range, setValue }: BarChartRaceContext =
getContext("BarChartRace");
$: max = $range[$range.length - 1];
$: min = $range[0];
Expand Down
8 changes: 6 additions & 2 deletions tests/bar-chart-race.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ describe("BarChartRace", () => {
test("TwoWayBinding", async () => {
const target = document.body;

instance = new TwoWayBinding({ target });
instance = new TwoWayBinding({
target,
});

expect(target.querySelectorAll("li").length).toEqual(5);
expect(target.querySelectorAll("li")[0].innerHTML).toMatchInlineSnapshot(
Expand Down Expand Up @@ -57,7 +59,9 @@ describe("BarChartRace", () => {
test("KitchenSink", async () => {
const target = document.body;

instance = new KitchenSink({ target });
instance = new KitchenSink({
target,
});

expect(target.querySelectorAll("li").length).toEqual(5);
expect(target.querySelectorAll("li")[0].innerHTML).toMatchInlineSnapshot(
Expand Down

0 comments on commit ae81421

Please sign in to comment.