Fork me on GitHub
#squint
<
2023-11-24
>
borkdude10:11:01

Hmm, somehow the import maps stuff doesn't work properly on my iPhone SE with iOS 15.8 (even though I have a shim from jspm in there): https://squint-cljs.github.io/squint/?src=https%3A%2F%2Fgist.githubusercontent.com%2Fborkdude%2Fca3af924dc2526f00361f28dcf5d0bfb%2Fraw%2F09cd9e17bf0d6fa3655d0e7cbf2c878e19cb894f%2Fpinball.cljs It does work on an iPhone 13 mini with iOS 16.6.1

1
borkdude10:11:34

Ah it works again, I screwed up some script tag

borkdude11:11:52

The squint playground now auto-saves your state so when you're working on an Advent of Code solution, you don't accidentally lose it when refreshing the window

🙏 1
guliy14:11:08

In React Native, using such constructs to combine styles is a common pattern:

<Pressable style={[styles.button, { backgroundColor: "#fff" }]}>
styles.button is js-object with stiles created by StyleSheet (abstraction of CSS) If i try write it like
[:Pressable {:style [styles.button {:backgroundColor "#fff"}]}] 
l’ll get
<Pressable style=<styles.button backgroundColor="#fff"></styles.button>></Pressable>
Of course there is couple workaround, but it would be nice to support this syntax

1
borkdude14:11:28

I am looking at your PR now. A small adjustment: if you write a component name, don't use the keywords, use Pressable. This will also make the function "used" for the linter: Note that I wrote :View here but changed the rest:

borkdude14:11:46

I will make these adjustments and then merge the PR manually

borkdude14:11:00

Now for your request, let me take a look if I understand it

borkdude14:11:03

What is the non-sugared equivalent of

style={[styles.button, { backgroundColor: "#fff" }]

guliy14:11:37

merge or assoc )

borkdude14:11:05

I don't know what the above compiles into

guliy14:11:14

i don’t no about js too, maybe it doesn’t exists

borkdude14:11:01

This does compile into JavaScript in the end right?

borkdude14:11:03

let me ask another way: what is the semantics of the above

borkdude14:11:32

you copy styles.button but add another key?

guliy14:11:20

it merges styles

borkdude14:11:31

Why don't they write this as:

{...styles.button, backgroundColor: '#fff'}
?

guliy14:11:30

:man-shrugging:

borkdude14:11:32

In squint we have:

{:& (.-button styles) :backgroundColor "#fff"}
for this

guliy14:11:58

I think this creates a new object and loses the magic of using StyleSheet, which caches styles for reuse

borkdude14:11:57

ok, I'll play around locally to see how it works

guliy14:11:04

I think it’s not such a big problem,

{:& (.-button styles) :backgroundColor "#fff"}
looks nice

borkdude14:11:34

except that it doesn't work yet in a nested fashion I notice now

borkdude14:11:46

let me see if I can fix that

guliy14:11:20

I think there is no need for nesting here at all. For nesting there is special method in StyleSheet

borkdude15:11:01

nesting as in: {:style {:& styles.button ...}}

borkdude15:11:17

it only works in the outer map right now

guliy15:11:02

it more complex situations better use

guliy15:11:28

const text = StyleSheet.compose(page.text, lists.listItem);

borkdude15:11:45

where can I find documentation about this syntax?

style={[styles.button, { backgroundColor: "#fff" }]

borkdude15:11:03

I think it's a different case than the spread one

borkdude15:11:04

where on that page is the description of the syntax?

guliy15:11:48

I haven’t seen a description of this particular syntax anywhere, but it appears everywhere

guliy15:11:26

i try to translate to squint this example https://docs.expo.dev/tutorial/build-a-screen/

borkdude15:11:53

@U5B5BAVB6 try this:

{:style (do [styles.container {:backgroundColor "#aff"}])}

borkdude15:11:30

It seems to be interpreting the value as another jsx tag because it's a vector

borkdude15:11:33

which is probably a bug

borkdude15:11:43

but when you wrap it in a do it will treat it like a normal value

guliy15:11:03

it works!!

🎉 1
💪 1
borkdude16:11:23

@U5B5BAVB6 should be fixed in v0.4.61

1