HTML doesn't have a way of expressing logic, like conditionals and loops. @sveltejs does.

Let's take a look at the 1st logic block in @sveltejs, πŸ‘‰ {#if} πŸ‘ˆ

πŸ‘‡πŸ§΅ [THREAD]
If you prefer watching video, the following thread is a summary from my @YouTube video
πŸ’‘{#if} is our 1st logic logic block in @sveltejs
πŸ’‘it allow us to conditional render content
πŸ’‘if comes with else, else if, just like you would expect in JavaScript <script>   let value = 42; </script>  {#if value === 42}   <
πŸ’‘you can have as any elements inside the {#if}, {:else}, {:else if} block <script>   let value = 42; </script>  {#if value === 42}   <
πŸ’‘like any logic blocks, you start with '{#', and end with '{/'
πŸ“ such as {#if} ... {/if}, {#await}...{/await}, {#each}...{/each}

πŸ’‘anything in between, use {: {#if ...}   <div /> {:else if ...}   <div /> {:else}   <div {#await ...}   <div /> {:then ...}   <div /> {:catch}   <div
πŸ’‘ If you want to conditionally show different text, you may want to use a ternary operator instead 😏 <div>   {condition ? 'xxx': 'yyy'} </div>
[END] Follow @lihautan for more content like this, we are going to look at each next!
@cadars oh hey look img alt text! 😏

β€’ β€’ β€’

Missing some Tweet in this thread? You can try to force a refresh
γ€€

Keep Current with Tan Li Hau πŸ€”

Tan Li Hau πŸ€” Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @lihautan

29 Jun
How do you pass dynamic data when you forward slots in @sveltejs?
Let's recap, here is how you forward slots
and here is how you pass dynamic data into slots

Read 11 tweets
15 Aug 20
Another week on #CSSpodcast, this weeks topic is CSS Functions 😍

🧡
CSS Functions provides runtime contextual expressions that return dynamic real-time value per the state of the browser per user in that moment
- global space, no need import
- can be nested, calc(var(--var))
- typed, eg: `rotate(45px)` will not work
- keep the function live, recompute on value changes and updates
- many of them are pure functions, however, counter-example: `counter()`
Read 20 tweets
12 Jul 20
In the latest episode #CSSpodcast, @Una and @argyleink shared a ton of pseudo-classes

(I managed to note down 3️⃣9️⃣ of them 😱)

🧡 Here is a thread of what were shared in the podcast πŸ‘‡πŸ‘‡πŸ‘‡
Pseudo-classes are selectors, lets you apply style to element based on info outside of the doc tree:

🌎 meta information, eg: language, history of navigator
β˜‘οΈ state of the element, eg: checked, active, disabled

✨Pseudo-classes are great for implementing micro-interactivity
πŸ”€ Case-insensitive
⏹ No whitespace in between
Read 24 tweets
7 Jul 20
Been using @reactjs for years, here is how @sveltejs code is different from @reactjs

1️⃣ Stateless Component ImageImage
2️⃣ Fragment

😍 You don't need a Fragment to group multiple elements in @sveltejs ImageImage
3️⃣ Inline styles

πŸ™†β€β™‚οΈ You can extend and manipulate the style object in @reactjs
πŸ™…β€β™‚οΈ It's a bane to copy the styles from the DOM into the code after tweaking it in the browser devtools
😍 So much easier when you can just copy the inline styles from browser into your code. ImageImage
Read 15 tweets
1 Jul 20
Learned a ton of pseudo elements, that i didnt know existed, in this week's #CSSpodcast by @Una and @argyleink

thecsspodcast.libsyn.com/014-pseudo-ele…

Learn about 9️⃣ things I learned in the thread πŸ‘‡πŸ‘‡
1️⃣

pseudo elements has 2 colons in front ::
πŸ†š
pseudo class which have 1 colon in front :
2️⃣

::before and ::after targets the pseudo-element that is the 1st child and last child of the element respectively

πŸ“ to create the pseudo-element, use `content` property
πŸ“ content will be read by screen reader
πŸ“ cannot be used by replaced elements, eg: <img>, <video>
Read 10 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(