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

Uses shadow dom to encapsulate styles #8

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
15 changes: 12 additions & 3 deletions client/src/App.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script>
import TailwindCss from "./lib/TailwindCSS.svelte";
import WeatherOverview from "./lib/WeatherOverview.svelte";
import { getForecastPoint } from "./lib/utils";

Expand All @@ -10,8 +9,18 @@
export let forecastPoint;
</script>

<TailwindCss />
<main class="flex justify-center mt-2">
<main
class="flex justify-center mt-2"
style={`
line-height: 1.5; /* 1 */
-webkit-text-size-adjust: 100%; /* 2 */
-moz-tab-size: 4; /* 3 */
-o-tab-size: 4;
tab-size: 4; /* 3 */
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; /* 4 */
font-feature-settings: normal; /* 5 */
font-variation-settings: normal; /* 6 */`}
>
{#if forecastPoint}
<WeatherOverview
{forecastPoint}
Expand Down
3 changes: 3 additions & 0 deletions client/src/lib/TailwindCSS.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
5 changes: 0 additions & 5 deletions client/src/lib/TailwindCSS.svelte

This file was deleted.

7 changes: 6 additions & 1 deletion client/src/main.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import App from "./App.svelte";
import TailwindCSS from "./lib/TailwindCSS.css?inline";

document.querySelectorAll(".srf-weather-widget").forEach((element) => {
const shadowRoot = element.attachShadow({ mode: "open" });
const shadowStyles = document.createElement("style");
shadowStyles.innerHTML = TailwindCSS;
shadowRoot.appendChild(shadowStyles);
new App({
target: element,
target: shadowRoot,
props: {
size: element.dataset.size,
mode: element.dataset.mode,
Expand Down