Skip to content

Commit

Permalink
Make asset paths configurable
Browse files Browse the repository at this point in the history
Signed-off-by: Rūdolfs Ošiņš <[email protected]>
  • Loading branch information
rudolfs committed Aug 5, 2022
1 parent 74c7bb7 commit 9aed77e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 2 additions & 4 deletions Emoji.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@
type EmojiSize = "small" | "regular" | "large" | "huge";
import twemoji from "twemoji";
import { config } from "./lib/config";
export let emoji: string;
export let size: EmojiSize = "regular";
export let style: string | undefined = undefined;
// Set this to an empty string if you need a relative asset path.
export let assetPathPrefix: string = "/";
</script>

<style>
Expand Down Expand Up @@ -49,7 +47,7 @@
<div {style} class="container">
{@html twemoji.parse(emoji, {
className: `emoji ${size}`,
base: assetPathPrefix,
base: $config.assetPathPrefix,
folder: "twemoji",
ext: ".svg",
})}
Expand Down
15 changes: 15 additions & 0 deletions lib/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright © 2022 The Radicle Design System Contributors
//
// This file is part of radicle-design-system, distributed under the GPLv3
// with Radicle Linking Exception. For full terms see the included
// LICENSE file.

import * as svelteStore from "svelte/store";

interface Config {
assetPathPrefix: string;
}

export const config = svelteStore.writable<Config>({
assetPathPrefix: "", // Set this to "/" for an absolute asset path.
});

0 comments on commit 9aed77e

Please sign in to comment.