From d2d15b35513b88b4d40c5688836cbea911db485f Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 9 Sep 2020 23:29:13 -0400 Subject: [PATCH 1/2] add local styles RFC --- text/0000-local-styles.md | 136 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 text/0000-local-styles.md diff --git a/text/0000-local-styles.md b/text/0000-local-styles.md new file mode 100644 index 0000000..f7b2026 --- /dev/null +++ b/text/0000-local-styles.md @@ -0,0 +1,136 @@ + +- Start Date: (fill me in with today's date, 2020-09-09) +- RFC PR: (leave this empty) +- Svelte Issue: (leave this empty) + +# Local styles + +## Summary + +Allow components to contain ` + + + +``` + +This would be roughly equivalent to the following... + +```svelte + +

some red text

+ +
+

some bold red text

+
+ + +``` + +...except that both `p` selectors would have the same specificity, with the priority determined by the order of the declarations in the outputted CSS (with deeper style elements following shallower/top-level ones). + +In terms of rendered HTML and outputted CSS, it would look something like this: + +```html +

some red text

+ +
+

some bold red text

+
+``` + +```css +p.svelte-abc123{color:red} +p.svelte-def456{font-weight:bold} +``` + +Alternatively, this: + +```html +

some red text

+ +
+

some bold red text

+
+``` + +```css +p[class^="svelte-abc123"]{color:red} +p.svelte-abc123-1{font-weight:bold} +``` + +Local styles would apply to blocks, not just elements: + +```svelte +{#if condition} + +

condition green

+{:else} + +

condition red

+{/if} +``` + +For now, adding the `scoped` attribute is necessary for this to not be a breaking change, since non-top-level `