Small is Beautiful #8
Videos āµ Small is Beautiful āµ #8
An unscheduled Small Is Beautiful episode for the Svelte Nano Donation component release.
Broadcast on April 8, 2021
An unscheduled Small Is Beautiful episode for the Svelte Nano Donation component release with Laura and Aral.
We covered:
- using it with SvelteKit
- using it in plain HTML/CSS (via Vite)
- accessibility considerations, etc.
Aral: Hi, Iām Aral Balkan,
Laura: and Iām Laura Kalbag, and together we are Small Technology Foundation, a teeny tiny little not-for-profit here in Cork in Ireland, and for once weāre in the same room.
Aral: We are in the same room. And this is a special edition of Small is Beautiful. And the reason we were chuckling when the the stream started is we were battling for focus from the camera because itās got a 1.4 f1 lens on it, which is excellent unless you want two people in focus at the same time. And it seems to like Laura better so⦠there we go. All right. Itās going to work. Itās going to work here. Itās me, Iām talking right now.
Aral: OK, there we go.
Aral: So this is a special edition of the stream because normally we are on on the third Thursday. [laughs] No, itās still following you, Laura.
Laura: Iām trying to hideā¦
the third Thursday⦠just looks like I have like an odd body. Anyway, itās usually on the third Thursday of the month, which we didnāt really realise is next week. So we thought, you know, we have this component we want to release for the nano cryptocurrency. Because like over the weekend, the nano community donated something like a 130 nanos, which is about, I donāt know, about 600 euros or so because we implemented a nano donation form on our website and we thought weād do something nice and pull that component out, make it a reusable component that anyone can use, any not for profit can include on their site to get donations and nanos, which is kind of cool.
Laura: Very cool.
Aral: Because. Well, because you donāt have to sign up for like a payment process or anything. You can actually just put it up there. And within minutes you could be taking donations.
Laura: So you donāt have to have all the banking stuff set up. You donāt have to have all the business stuff set up. Although you should be aware, you need to pay taxes on that stuff.
Aral: Well, if itās a donation, you probably donāt. But if itās not a donation, if youāre giving anything back, then you would. But that the thing with the component is itās a donation component. So you canāt actually tell, you know, when someoneās donated, etc. youāll just see it in your account, but you wonāt be able to say, oh, OK, well, you know, great. And hereās a t shirt to you. You canāt do that. That wouldnāt be a donation anyway. Thatās when youād have to pay taxes.
Laura: And thatās our small lesson in taxes.
Aral: Well, a lot of crowdfunding people get burned by that.
Laura: That is true.
Aral: So. All right. So letās get started. Let me just show you what it looks like. So Iām just going to switch to my screen over here, and you can see it here on the right. That is the demo that is at small-tech.org/svelte-nano-donate. So that demo, thereās also the source code for it, which Iāll share later and weāll look at the code and all of that today as well.
Aral: But just to show you how it works, this has been set up so that initially itās set for 10 US dollars. And what you do is, if you have your nano wallet on your phone, you can just scan this QR code. Or if youāre on your phone, of course, you canāt scan your phone with your phone, thereās a link that you can click and tap on your phone and that will actually take you to the app. So the component itself is very simple. If I reload the page, you kind of see that itās got a little pre-loader.
Aral: And then what thatās doing is loading the currency exchange rates and then you, the person whoās doing the donation, can actually⦠itās kind of cool⦠change the the amount and you see the QR code changing in real time there, Or they can change the the currency. So it could be euros. So just to show you how it works, Iāll just actually take it down to one euro. And letās go back to our camera here, and [laughs] Lauraās hiding, and Iāll just take my⦠Iāll open my Natrium app.
Aral: So Natrium is the there we go, so thatās thatās how much they donated over the weekend, the people in the community, thank you so much. That was really cool. Weāre going to keep those as nanos. Weāre going to start working with them. Lauraās doing a thumbs up. You canāt see it. And so on the Nano app, you have these buttons you can say āreceiveā and āsendā. So Iām just going to say āsendā. OK, so then it says āsend fromā, āenter amountā or āscan QR codeā.
Aral: So Iām just going to go to āscan QR codeā. And just going to⦠there we go and it says āyou are sending 0.2 nanosā, which is, I guess, one euro, to our address and āconfirmā or ācancelā. So Iām just going to say āconfirm.ā Itās got my face ID, and it sent the nanos. And Iām going to close this. And letās just see here. Was that 0.2? [Amount in account on screen increases by 0.2.] There we go. That thatās the amount at the top that just arrived
Aral: And, yeah. Is that the? Yep. Thatās the one that we just sent. So thatās how quick it is as well, which is just so amazing. Of course I just sent it to myself. So thatās, you know⦠and there are no fees with Nano as well, which is very, very cool.
Laura: Well I thought, actually. Just, it might be worth quickly explaining why, Nano? Given that cryptocurrencies is such a big thing, and you might have heard both of us probably saying that we are not general fans of cryptocurrency for reasons both social, cultural and environmental.
Aral: Right, right. And actually, on that note, letās also put up the URL where you can join us in the studio. If you have a camera and if you have headphones, if you hit that link, youāll join us in the studio that weāre actually presenting this from. We have space for nine other people. And if you have any questions or you want to join the conversation, if you have any thoughts, et cetera, you can join us at that URL and we can put you live and youāll be live on the stream. But just make sure you have headphones so we donāt get any feedback.
Aral: And Laura, if I forget to take that off when Iām doing my demos, please tell me to take the lower third off. OK, so the question was, well, we have so many reservations about blockchain and cryptocurrency, so why Nano? Why add Nano our to our sign up form? And on our form. So if you actually go to small-tech.org/fund-us, youāll see where the form originated. So this is our Fund us page, and originally we just had the card, the credit card payments here.
Aral: You could choose a monthly or a one time donation. And this is basically blatantly ripped off of the Wikipedia donation form. And you become a patron, and the card would take you to Stripeās, if I said become a patron there, we get the Stripe sort of form there. But then we added Nano. So this is where the form originated. Weāve actually pulled it out. The component that we have now is much nicer because we had a couple of days to work on it this week, so we were able to really refine it. But this is where it originated.
Aral: So why did we add this? You know, if we have such reservations about cryptocurrency, and blockchain? Well, for one thing, theyāre not all the same. So what are you doing?
Laura: Donāt worry.
Aral: OK. You were watching the stream on your phone.
Laura: I was trying to get access to the chat so that I could see what if we had questions.
Aral: OK, all right.
Laura: Iām trying to be too clever for my own good.
Aral: Thatās fine. [laughs]
Laura: Sorry, I apologise for the interruption.
Aral: So to get back to the question, which I still havenāt answered, why Nano and not these other blockchain things? So first and foremost, personally, Iām not opposed to the idea of a digital currency. What I am opposed to is proof of work mining, which is used in blockchain, which is used in, sorry, Bitcoin and in Ethereum on the Ethereum block chains and the forks and the alt coins, et cetera, that are based on those. So proof of work mining is basically in a nutshell, wasting huge amounts of energy, running the same meaningless hash algorithm over and over again until you hit the jackpot.
Aral: Lots and lots of computers around the world and specialised ASIC units, etc. doing this, wasting huge, huge amounts of energy, more energy than itās used by certain countries in the world. And why? Well, just so a handful, a literal, like a relative handful, of libertarians, right libertarians can get even richer. So, yeah, weāre not about that at all. Nothing about that excites me. That actually disgusts me. I think that proof of work mining should be considered a crime against humanity.
Aral: That doesnāt mean that weāre against the concept of having a digital currency. And in fact, at some point, you know, we are going to move to those currencies. There are things to be worried about there as well, because as we move to what some people are calling a ācashless societyā and, we kind of experienced this firsthand in Sweden a little bitā¦
Laura: Where they are big time into cashless, they wonāt take cash anywhere.
Aral: Right. But whatās the alternative thatās being posed there? The alternative is credit cards from banks. So letās just as a hypothetical think what happens, what kind of world do we get if thereās no cash whatsoever? And the only way you can buy food and the only way you can buy something to drink is with your bank-issued card. Right? Thatās fine. Right? I mean, we have nothing to worry about. We trust the banks. The banks are lovely people. The governments are lovely people. Until you become someone that maybe criticises the government or criticises banks, suddenly you canāt get a debit card. So.
Aral: But you still need to eat to live. Right? But thereās no cash. What happens? I mean, thatās an extreme case, but thatās not a case that I you know, that that couldnāt happen. You know, you look at the kind of bank blockages and sanctions that are put on people who do speak out against⦠who are whistleblowers, et cetera. And you can see that sort of thing happening. So we do need alternatives in such a world that are not controlled by a handful of banks and not controlled just by governments.
Aral: So I think itās you know, we definitely need to be investing in alternatives that are digital. But at the same time, you know, how these currencies are distributed is very important. So when you create a currency is eighty five percent of it kept by a small group of people? And some of it distributed in theā¦
Laura: essentially a digital pyramid scheme.
Aral: Well, yeah. And weāve also created new kings at that point. Right? Weāve created a new monarchy and theyāve just minted their own coin. And those people will say, well, thatās what the central banks do. Exactly. I mean, money is is a fiction, right? Itās a fiction we agree on. A central bank literally creates money out of thin air the moment they say this money exists in their ledger. So itās not that different really to a digital ledger.
Aral: So we do have two people in the in the studio. Iām not sure if theyāve⦠if you want to use the private chat and let us know if you want to ask a question or if you want to join the conversation, just use the private chat.
Aral: You should see it in the interface. Thatās Duncan and NanoLover. Duncan is just lurking. OK, Duncan says Iām just lurking. OK, so thatās really important. So with Nano, there is no proof of work mining. There is a small amount of proof of work thatās performed when youāre actually making a transaction and thatās performed in your own wallet. And thatās a completely different thing. So Iām⦠from what Iāve seen looking into it, it was distributed in a fair manner. The people around it I mean, thereās a foundation around that. The people around it like I mean, hereās my criteria, right? Iām looking into this space. And if I see a community full of people with laser eyes in their profiles, then Iām going to be out of there, you know, in a New York minute. If I see always Trumpers, et cetera, in this community, thatās not for us. Right? So looking into Nano community, I saw a bunch of developers building things, people who really value that, a currency that is meant to be used.
Aral: So, I mean, all this to say, I mean, as a caveat, all of this. Currencies, money, et cetera, are things that I find very difficult to get excited about at the best of times, right? They are a fact of life. I donāt think that blockchain or cryptocurrency should be at the centre of any decentralised effort. So what weāre building with the Small Web is a world where we want to see everyone own and control their own place on the web, right at their own address, their own place where they can be private, truly private, where they only hold the keys and they can be public.
Aral: Now, if thereās going to be a currency thatās used in this sort of a system, it would have to be similarly topologically decentralised. And thatās something that Iāve seen in Nano. So in that everyone has their own directed acyclic graph. Right. So this is a sort of system that is very compatible with a concept like the Small Web where everyone has their own node on the on the Web. That could also be, say, a node that, you know, is your nano node as well. Iām not saying weāre going to build this in version one at all. No. What doesnāt make sense to me is like, oh, youāre building a decentralised network or a decentralised social network, youāre doing it on block chain, right? No. Why? Why would I do that? Thatās ridiculous. Why would we do that? Because the idea is not to create a world where we have a billion copies of the same database that we can prove that theyāre the same and that is decentralisation. No, thatās actually a very centralised system. I want to see a world where everyone has their own databases. If there are billion people, there are different billion data, a different billion databases, and they can all talk to one another. But people own these databases and theyāre all unique and different and they might reflect different aspects of ourselves. Anyway. So long story short, thatās thatās kind of why Nano was interesting to me with all of those caveats.
Aral: So anyway, to get back to this and get back to the component, because we said we were going to keep this one short. This is not a scheduled Small is Beautiful. Just wants to say thank you to the community and release the component. So just to show you how it works and how you would use it if youāre a developer. So. Well, I show you how it works. Thatās all there is to it, really. Laura, do you want to actually, before we go into how to build with it, do you want to just take us through? I can demonstrate.
Aral: Maybe you can talk about it. The various features we have, like weāve got dark mode supportā¦
Laura: Iāve got me a little list hereā¦
Aral: OKā¦
Laura: Put my phone on the floor andā¦
Aral: and Iāll drive.
Laura: Oh thatās great. Because, as Aral very well knows, I canāt use this keyboard to save my life because I have very small hands and his keyboard is like a piano.
Aral: Itās a lovely keyboard. Itās Real Force.
Laura: Itās awful. And you have to listen to the noise of it as well.
Aral: And I love it.
Laura: So. So one of the reasons that Aral and I work quite well together is that we both haveā¦
Aral: different keyboards [laughs]
Laura: different keyboards and we work in different rooms, but also that we have different skills and areas of experience and knowledge that are quite complementary and crossover in certain places as well. And one of the things that I really wanted when Aral mentioned the component that heās made, I was like, well, letās have a look at some of the accessibility of it to make sure that if weāre sharing something, we want to make sure that weāre sharing the most accessible thing that we can possibly share. And also, I had some ideas for some CSS kind of trickery that could actually just make it a little bit easier and make the styles a bit simpler for the component as well.
Aral: So letās letās show it off. Iām going to switch to the screen so that folks can see maybe should we start with dark mode?
Laura: Go for it.
Aral: OK, Iāll start off with dark mode then. So it has dark mode support. Thatās the thatās the gist of it really. So if we go over here to the preferences and I search for dark in Firefox, I can turn dark mode on and then boom, you see that we have the dark mode.
Laura: Itās remarkable that thereās not an easier way of doing it in the operating system. But I think that a lot of operating systems, for example, as people will previously know that I am a Mac user and itās disappointing to all. However, that is the dark mode support is often built in and you can just change it in your general settings in macOS that you just change what theme you want, I think they call it something like that.
Aral: And the next version of elementary OS, which is what Iām running, it has full dark mode support as well. So you wouldnāt have to do this.
Laura: Yes, we donāt talk badly about elementary OS in this house. If thereās a great feature, theyāre about to have it because theyāre good.
Aral: Well, and of course the difference is elementary OS is a free and open source operating system and itās not controlled by a trillion dollar monopoly, which is always good. So moving on. [laughs]
Laura: Moving on. Do you want to show your screen now?
Aral: What are we showing, reduce motion?
Laura: No, I think it would be a good point just to show the color theme bit, because thatās pertaining to the dark modeā¦
Aral: As in, like, showing how you change it in the code.
Laura: Mmhmm.
Aral: OK, well, in that case, let me actually go through actually how to set up a project and to use it so that we have that code.
Laura: OK, weāre having a little production meeting right here.
Aral: OK. Cool. All right. So I am going to show you how to actually use this component. Itās very simple. Iāll show you how to use it. Itās still on Laura [(the camera focus)].
Laura: Sorry!
Aral: It just doesnāt⦠Iām just going to be a blur in this in this one.
Laura: Stop leaning back!
Aral: So. You can use it in Svelte projects very easily, you can use it in non-Svelte projects as well, very easily. It is a Svelte component but Svelte components compile into pure JavaScript. So Iāll show you an example of both of those things. Letās start with Svelte, since itās a Svelte component and since SvelteKit is such a big thing. So letās start with that. So first of all, let me just open up a new tab here. Thereās Firefox with its little branding go Firefox. They get half a billion dollars from Google every year, in case you didnāt know that. Itās good to know.
Aral: So Iām just going to start a SvelteKit app. So Iāll make a folder and Iāll say, letās say svelte-demo and Iāll go into svelte-demo and npm init. I think itās svelte@next is how you install SvelteKit. Yeah, thereās a setup wizard. Iāll just use the defaults which just Iām just saying just use CSS so Iāll follow the instructions that itās given me.
Aral: Iām just doing an npm install to install the template itself and then it says run dev, Iāve already got my browser open so I wonāt do the ----open thing. But if I say npm run dev and I go to localhost:3000 where itās running, this is just the Svelte Hello World. [In bad European accent] Hello World⦠Hello World example from SvelteKit. [More bad European accent] Svelte, ya.
Laura: No, donāt. No accents.
Aral: No accents? OK.
Laura: No.
Aral: Right, back to the screen.
Aral: So this is just a regular SvelteKit app. OK, and Iām now going to open up my code editor. Whoa. That is not how that should have opened up, but thatās fine. Oh, great. There we go. Itās⦠every other time Iāve done it, the code editor has remembered its position that I paced painstakingly had put it into, but not this time. But there we go. So letās make that⦠not you, not you, there we go. Letās make that perfect. Yay! Why am I not using a tiling window manager? I donāt know. All right.
Aral: So if we look in /source and we look in /routes, you can see that thereās a general layout, very, very simple. Just loads the app, CSS . This is all SvelteKit. Right? Thereās a slot that your index page is going to slot into. And this is that index page. So in SvelteKit, if I was say āhello Nano folksā and save, you can see that with hot module replacement thatās there.
Aral: So letās delete all that and instead letās import our components. Right? So Iām going to import, nano-donate Iāll call it, from @small-tech/svelte-nano-donate and thatās the name of the component. Now did I install it? I didnāt. So letās do that. npm install @small-tech/svelte-nano-donate⦠so just installing the component right now, just so I can use it.
Aral: OK, so now I can just use it and I say ānano donateā and letās just see what happens if I just add the components on here. So for one thing I have dark mode on, so let me just turn dark mode off so it looks a little better while weāre looking at it. Another thing, Iāll just make this a little smaller so the whole component shows. All right. So it says initialisation error, missing property address. So if you screw up, it tells you youāve screwed up.
Aral: What are we missing? The nano address if my wallet. Right? So thatās the only thing that you actually need. And I donāt know why, but this SvelteKit template defaults to tabs instead of spaces. So that is really messing me up. So there we go. There we go. Spaces, I can breathe easily again because itāsā¦
Laura: What a hill to die onā¦
Aral: Itās an important hill do die on, I believe. I donāt know. Letās get back to it. So address=, and Iām just going to put in my nano address there.
Aral: And if I save now, itās operational. Right? Itās loading the value from⦠itās doing⦠thatās taken a long time ago. It was just slow. OK, the coin gecko API can be slow at times, which is why we have aā¦
Laura: A loading spinner!
Aral: ā¦progress indicator. Yeah, exactly.
Aral: So there it is. Itās running. And you can see that these are the default colours, for example. This is the default amount, the default currency there because we havenāt overridden any of them, but weāre up and running. You could just put this like live, on your site now. Just deploy your SvelteKit site and you have a means to take donations. Which again, I think is really, really cool for not for profits, etc⦠Right?
Laura: I mean, you just⦠itās that quick. Itās that easy. And you donāt have to worry about setting anything else up. Because if you set up a Stripe account and things like thatā¦
Aral: Stripe is excellent. Donāt get me wrong.
Laura: Yeah, but you have to go through the process to verify you and all of that. What if you just want to run a short campaign for something in particular? Youāre trying to raise funds for something, you donāt necessarily want to jump through all of those hoops.
Aral: I mean, itās awesome. If you can just start like that, then if you think no permission requiredā¦
Laura: And if you think about a lot of countries around the world have issues with these kinds of providers as well, particularly because of, I donāt know thereās levels of fraud, supposed levels of fraud, or levels of fraud in the country that means that they need extra verification and have to jump through even more hoops. Itās just not particularly fair. And so the idea was that this could be easy for everyone, hopefully.
Aral: Right. So this is all you need to do to get started with it in a Svelte project. Now you can customize it more. You want to set the amount like we had it before. Letās say you want that to be 10, boom, itās 10. If you want the currency to be something different like USD, so letās just recreate the one that we had, and then you can also do a theme so you can set the theme colour here. And that is the British spelling, yes, I know. To be contrarian. And as the colour lets just pass, I donāt know, a very garish blue. And then you have that theme colour and the border colour is calculated according to it. You probably have something to say there, Laura, about the contrasts.
Laura: So one of the things is really important in accessibility, probably the thing that you would notice the most as a casual user of the Web is the difference in the colour between the text and the background. And this is quite an important concept in accessibility, the idea of text contrast. Because if your text is a really light colour against a white background, it makes it much harder to read. And thatās not just for people who have sort of old screens or using their device in bright sunlight, but itās also for people who have impairments related to their eyesight, have difficulty seeing.
Laura: And so if we try to make sure that we use high contrast text, reasonably high contrast text, that way we know that weāre making Web pages that are accessible to the widest possible audience.
Aral: And if you actually go to the source code repository for the component, which is at github.com/small-tech/svelte-nano-donate, and you look at the readme, apart from instructions on how to use it, of course. If you scroll down youāll see under theming that there is a note there saying, please make sure you check the contrast ratio with a link to Lea Verouās online contrast ratio tool, which is very, very cool. So we could actually hear it⦠let me make this a bit smaller so you can see it. So we could actually I could pop the blue that we put here. That we were just using, and we can see that that blue is actually perfectly fine. Thatās garish, but itās accessible.
Laura: Yeah, it might not be the best taste and it might actually be a little bit bright, like for eyesight. And I donāt know about you, but my eyes hurt a little bit looking at that on white and it would probably be even more garish against black, but itās a good start, itās a good start.
Aral: There we go. So⦠and you can change and you can actually specify other things like the border colour, etc. if you want to overwrite them. Otherwise, theyāre automatically create for you. And of course, the dark mode setting as well will use those as well. It doesnāt look really great right now, dark mode on there, because in our app, the :root doesnāt actually have anything on it. So but if I go in there and and actually say background-color: white; for :root, and this is just in your own app, of course. And then if I do a media query, so if I say prefers-dark-scheme or, sorry, prefers-color-scheme: darkā¦then on :root weāll just say background-color: black; to match that, and there we go. That looks a little bit better.
Laura: Very nice. And one of the things that is worth mentioning that Aral did was he made the colours for the dark mode, it flips, so it also it uses your colour, but it makes it nice, a light version of itā¦
Aral: So itās still accessible. If you have an accessible colour, it should be accessible when the dark mode.
Laura: And youāre doing that using the invert filterā¦
Aral: the invert filter in CSS, which is very, very cool.
Laura: Yeah.
Aral: Yeah. Although actually talking about Lea Verou⦠if youāre into this stuff, what was herā¦?
Laura: You said it was on her homepageā¦
Aral: Yeah I did. Actually, letās just go back to the website for the component, because the link is there⦠to her website as well. So we search for āLea Verouā. OK, thatās her website. She actually has, her latest article, I just on there today when I was linking to her site, is Dark mode in 5 minutes with inverted lightness variables, which is actually a different way of doing what we did, but actually an even nicer way. This is very cool. So sheās using these percentages of a primary :root coluor here to set different colours. And so you get something like thisā¦
Laura: And thatās using the HSL colour units, which means you haveā¦
Aral: hue, saturationā¦
Laura: saturation and lightness, which means that you can tweak the lightness separately from the hue and the saturation, which is quite good if youāre just trying to change a shade of a colour.
Aral: Right. And so what she does in this is, for the dark mode version of it. Sheās actually setting up these percentages as CSS variables, and then in dark mode, sheās changing those percentages and flipping them around.
Laura: Yeah thatās very clever!
Aral: So thatās really clever. And so take a look at that as well. Weāre just using a very, very basic⦠so if I was to show you the⦠actually let me show you the source code from the component that we just downloadedā¦
Laura: Using CSS variables again, which I would really recommend looking into if you havenāt tried to use them yet, because theyāve got pretty wide support cross-browser nowadays, and if youāre familiar with the world of SASS or Stylus, youāll be familiar with the concept of using variables in CSS. But this way you can do it just in vanilla CSS. And the way I see it, nowadays, vanilla CSS pretty much has most of the features that you would have previously, or certainly I would have used, in SASS or Stylus. And so itās really great to take advantage of that and not have to have all that abstraction.
Aral: And so this is how weāre doing the component, using the invert filter with a hue-rotate and the hue-rotate is important to keep the same hue, so that it doesnāt just invert and you get that kind of traditional inverted look where youāre just like where they pick this horrible colour from? Youāre rotating at 180 degrees. So you keep the hue, which is very cool. And Iām just re-inverting the canvas afterwards. So the QR code is being rendered into a canvas. So Iām re-inverting the canvas because I donāt want the QR code could be to be inverted. Some readers are fine with inverted QR codes, but not all of them. So thatās that.
Aral: So this is how you would use it in a Svelte application like SvelteKit, which is like very hot right now. Itās not even out. Itās just beta. But what about any other app, like a just a general website you want to add this on to? Right? So let me show you that as well.
Aral: And to do that, Iāll use Vite, just so we can actually have a framework for, sorry, a scaffolding kind of for importing ES modules, and using them. And using it for importing as well as the component using it. You can also do this by just using something like Rollup or even Browserify etc, but Iām just going to use Vite for it. So Iāll say⦠letās go over here to my site⦠so Iāll say vite⦠npm init vitejs/app, I think is how you start a ViteJS app if I remember correctly. Letās see⦠no, that is not how you do it. npm init vitejs/app⦠vite app? Was it vite app?
Aral: Letās go to ViteJS and find out, come on. Theyāll tell us, theyāll tell us how to do it. So whereās that Getting Started button? There we go. Tell us how to do it⦠@vitejs/app! Thatās it, @vitejs/app. And weāll call it nano-donate, and weāre going to create a vanilla CSSS HTML project, OK? So Iāll go into nano-donate, npm install. And open up my code editor there. Of course, itās going to remember the wrong size again because why not? Why not? Itās not like I ran through this earlier, made sure it was the right size, made sure it remembered it. But, hey, growing pains⦠itās⦠this is basically so that you all can see all of the components, itās a very high resolution, thatās also part of the problem. And elementary OS doesnāt really necessarily like it, that Iām at such a high magnification on myā¦
Laura: You donāt need perfection.
Aral: Itās fine. So here we go. And letās also run that. So Iām going to npm urn devā¦
Laura: It worked!
Aral: [laughs] It did⦠common enough mistake. There we go. So if I refresh here now.
Aral: Oh, itās on :3001, OK, thatās our previous site. Hello Vite! Yay!
Aral: And how does that work? So thereās an index file here, and you can see that they have a <div>. This is all HTML. They have a <div> called id="app" and they have a script that theyāre loading in called āmainā. If we jump to that main script, you can see that thereās just a query selector, and theyāre setting the innerHTML to the message that weāre seeing there. OK, so letās delete that. In index.html, Iām just going to call this nano-donate⦠you can call it whatever you want. Iām just saying thatās my component. Again, Iām going to install, npm install @small-tech,/svelte-nano-donate. So Iām going to install the component just like I did in the Svelte application, and then over here Iām just going to import it just like I did previously. So Iām going to say import nano-donate from @small-tech,/svelte-nano-donate. But this time, itās not a Svelte app, right? Thatās fine, because nano-donate is actually just a JavaScript class and so itās⦠[focus] still on Laura. Letās see if you can get it there again. Hi. Hi! So nano-donateā¦
Aral: So nano-donate⦠again straight to you. It loves you. Itās just⦠there we go. Maybe⦠is just a class, itās just a JavaScript class. All right? So letās go back here. And so all I need to do is⦠instantiate it. So Iām going to say new NanoDonate() and Iām going to give it a target. And as a target, Iām going to say document.getElementByID() and we called it nano-donate? We should have called it nano-donate. I used camel case. Letās use a dash instead. And if I do that, actually, and I save this, you can see, OK⦠letās get out of that dark theme colour as well, so it looks a bit better. OK⦠so as you can see, this is exactly where we were previously. Only, of course, the component doesnāt specify any fonts. Itāll use the fonts that your site uses. And so our style.css doesnāt have that, have any fonts that are applying to this right now because the size or scope, I guess. So here Iām going to just pass my props, my properties, as an object this time. And again, itās just the address thatās missing. Right? So if I just go back and I say address over here and I save, boom. Weāre back to where we were. Right? And you can also do again, you can do amount, and that was 10, right. And you can do currency, and that was euro. Oops, donāt forget the comma and itās working exactly as it was. And then you can even pass the theme and then you can pass the colour. And we had⦠what was it? #0000ff, and weāre basically back to where we were. But this is plain HTML, CSS and JavaScript, so you can just use that component that easily in any app, really. Is there anything we havenāt mentioned yet?
Laura: Well, weāve got a few things that we want to talk about from the accessibility side of things.
Aral: Prefers-reduced-motion?
Laura: Yeah.
Aral: Alright.
Laura: First things first, and you can demonstrate this, Aral, on the screen asā¦
Aral: OK.
Laura: ā¦Iām saying it. One of the key things when it comes to accessibility and forms is can people use the form? And one of the things that we so often forgets about is the idea of being able to keyboard-navigate. So if you tab through the form elements, can you see whatās actually active, whatās actually got the focus at the time? Because thatās very important, not just for people who just use keyboard navigation, but if you think about assistive technologies like screen readers, those are using⦠often used⦠with keyboard navigation, not exclusively, but very often.
Laura: And so you want to make sure that all of those form eleements are essentially āvisibleā in all possible senses of the word. So the keyboard navigation is incredibly important. Making sure that you have focus styles on that keyboard navigation. So, Aral, if you just switch back to the screen briefly. So itās quite difficult here to see because the colour that Aral has chosen is quite similar to Firefoxās default colour focus stylesā¦
Aral: I can change thatā¦
Laura: But now if he tabs through, you can see that thereās that kind of bluish outline. And then when it goes around the link, itās a kind of a dotted outline and itās just those little styles that make sure that you can see whatās active. And I think that thatās such a common thing, that people will apply a CSS reset that wipes out focus styles. So itās a really good tip to just make your site more accessible, go in and make sure, and thatās using the pseudo selector, the little : focus. And you can apply your styles from there. What I would say is⦠by default, donāt mess with the browser defaults. Theyāre usually fine, they could be better, they could be a bit higher contrast sometimes. But if youāre not⦠if you donāt know what youāre doing or youāre not really sure, leave them at default. Just donāt disable them. And then if you want to make it something a bit more high contrast, a bit easier to see, then you can do that. For this component, weāre not going to be setting focus styles because if theyāre different and inconsistent with the rest of the page that theyāre on, or other elements of the page, thatās not going to be easy to use. You want to make sure that youāve got consistency across the whole site.
Aral: Right. Which also just reminds me, there is also some basic error handling that we put in as well. So if, for example, letās go to the preferences. No, actually, letās go to⦠was that closed? Letās go to the Developer view here, Network view. So letās say, for example, that the coin geko API call failed on your site. What would happen? So letās refresh. You get a network error. If coin gecko comes back and you try again, then it works. So weāve you know, this stuff actually doesnāt exist in our component, on our website yet, but itāll be interesting to apply some of these things that weāve implemented for this component.
Aral: But thatās thatās whatās so interesting, actually, because if you think about the amount of time that goes into making something like this⦠and again, like this is over the weekend, that the nano donation thing happened⦠Because somebody donated for the first time, and I tweeted about it. And then people were like, I think the Nano folks retweeted it or they wrote a tweet about us accepting it, and then it just kind of took off from there. So whoever did the first donation, thanks so much. You just kind of sparked the whole thing that gave us all those donations. But⦠and I started working on it, I think it was on the Monday, or the Sunday to Monday.
Aral: And the component was basically āreadyā, as in doing the main thing that it does, kind of on Monday, it was like it was like, you know, just a couple of hours.
Laura: To have the basics, yeah.
Aral: So to pull it out and to make it into a Svelte component. But actually, if you look at the Git log of it, because this is really actually quite interesting⦠Where are? Oh thatās not the⦠I need to actually go into the actual component itself, and show you⦠svelte-nano-donate. OK, if we look at the log of that, you can see that this tag, the 1.0 tag, was like three commits in. And I was like, yeah, yeah, this is ready. Itās doing whatever itās doing.
Laura: Cocky.
And then in the next few days, these are the tags that weāve had as we went through, and we added the input, we just layered on the accessibility issues, the accessibility supports, the error handling, this and that, checking on different browsers. And thatās where all the other commits came in. So I think thatās kind of important to keep in mind when youāre building anything really. Right?
Laura: Yes. I mean, making sure that you pay attention to the priorities as well, before you release something.
Aral: Yeah.
Laura: It can be very easy thinking oh, yeah, got it done. But actually, accessibility is one of those things that always falls by the wayside, particularly for people who donāt have accessibility needs themselves. Because itās not necessarily always at the forefront of your mind. And so itās pretty good if you work on a team to hold each other to account for those kinds of things.
Aral: Yeah, and I mean, if you look at the days as well, so 1.0 release was two days ago. Right? And then weāve got like the work, two days ago, 30 hours ago, etc⦠And then this rush over here [laughs] was when I realised that the QRious component that Iām including, which is a common.js component, works perfectly well with SvelteKit, which is, again, itās still beta, SvelteKit, it is still beta. So remember that. But when you⦠works perfectly well if you are using the component locally, linked locally, but the moment you get it from npm, like I installed it, it just baulks. Thatās something Iām sure theyāre going to fix. But I had to inline it with about two hours to go, which was fun.
Laura: So one of the other elements that we worked on wasā¦
Aral: Reduce-motion?
Laura: Yes, Iām getting to it!
Aral: Sorry.
Laura: It was a loading spinner, which you might have seen in right at the very beginning of the stream when we first loaded the component in, was that when youāre trying to pull the currencies from the API and the⦠it sometimes takes a bit of time, particularly if youāre on a slower network. And so we wanted to make sure that people knew something was happening, that things werenāt broken, and so Aral started off with a nice little loading spinner component, that I think was a component, was that right?
Laura: And then we worked on ways to make that more accessible, because if you think about it, by default an image swirling around, thatās not going to be much good for assistive technologies, for people who canāt see that on the screen, they donāt know whatās going on, and so one of the things that we did was we added some text, just a bit of paragraph text that explained that⦠I think itās something like āCurrencies loadingā¦ā And then the⦠sorry I wasnāt sure what you were doing⦠and so we had that text so thatā¦
Aral: was getting the loading spinnerā¦
Laura: was simple to people that couldnāt see the contents of the screen, and we use CSS to ensure that happens. And then one of the other things thatās important, when youāre putting in things like CSS animations, or any kind of animation onto a page, was the motion. Because motion is actually a potential trigger for people with epilepsy, people who have vestibular- disorder and people who are just otherwise motion sensitive. So, for example, when I was doing CSS dev work on this component and I⦠so I froze it were just the loading point so I could work on positioning and things like that, I was getting giddy just looking at that thing. So you donāt want to be making someone potentially ill, triggering something in someone with your animation. You donāt need to. And itās really great because we have a media query called prefers-reduced-motion. And thatās another thing that you can set in your operating system settings or in the browser. And I think Iām not sure⦠for you, where do you set that setting?
Aral: You⦠Well, on Elementary OS, there isnāt a setting for that right now. I tried to find it. You can install Elementary Tweaks and then set animations off. That still doesnāt set it for the browser. So thatās what I was showing earlier on Firefox. What you can do is, let me just show you the screen. You can create a property called ui.prefersReducedMotion, and if you set that to 1, then you will have set that on, it needs a number property. So not ideal, but something that Iāll talk to the elementary folks about.
Laura: Right. And so if youāre using macOS, you can itās in the accessibility settings for the operating system. You can take a box that says, or check a box if youāre American, that says āReduce motionā and the browser will have that flag for websites. And so you can just use a media query to target the situation when people prefer reduced motion. And so what we did was we used that in order to⦠initially we thought weād stop the animation and just have it just an image. But then we thought, whatās the point? So we hide the animation. Thatās what weāre doing now, isnāt it? Hidingā¦
Aral: I just showed that, while you were talkingā¦
Laura: showing the text alternative that we initially did for screen readers, but also thatās beneficial for this situation as well. Which is just showing that text alternative to things are always a good idea.
Aral: There we go. And thatās the component. So we do have Duncan and NanoLover in the in the chat. Iām not sure if either of you⦠well, neither of you seem to have a video, so we canāt really add you to the stream. But thank you for joining us. If thereās anyone else who wants to join, oh, someone getting a video connection. No. Hey! We can add Duncan. Duncan, can we add you?
Laura: Does he want to be added?
Aral: Can we add you?
Laura: Do a thumbs up.
Aral: Do a thumbs up if we can add you to the stream.
Laura: Oh, heās got dinner. Time to go. But itās nice to see your face!
Aral: Oh, OK. Well take care. At least we saw you in a thumbnail. Take care. Bon appetit. All right. So I think weāre good. It doesnāt seem to be.
Laura: I mean, itās been quite a long mini livestreamā¦
Aral: We are going to have are our regularly scheduled Small is Beautiful is next week. Actuallyā¦
Laura: Yup.
Aral: I didnāt realise that, because the 1st was actually a Thursday. So maybe weāll look at⦠weāll see if we can get someone from like the Nano Foundation or the community to join us or what do you think?
Laura: Yeah, maybe weāll try and do something with that.
Aral: Yeah. Or maybe weāll get some some people from the⦠weāll have a cryptocurrency-based related-thing.
Laura: And then we can look more at the issues around the outside, not just the technical side.
Aral: Yeah. Not the technical side. But yeah. So anyway I hope this is useful. If you want to see a demo of it you can go to small-tech.org/demo/svelte-nano-donate. Oh Carlās joined. OK, letās see if Carlās got a webcam. Maybe we can add Carl to the stream if he doesā¦
Laura: Weāre wrapping upā¦
Aral: Itās so small-tech.org/demo/svelte-nano-donat and yeah. So that I hope that the some if there are not-for-profits et cetera, who were looking to maybe add to whatever donation systems they have, very, very simple component. Weāve kind of, you know, itās an accessible component. And I think itās about as easy to add to your projects as can be, for developers. So, you know, I hope it helps some people out there. We just want to say a little thank you to the community for their donations over the weekend and. Yeah, well, yeah, I donāt think Carlās got⦠no camera or mic, says Carl. Well, thank you for joining us still, Carl. And thank you to those of you who are watching right now. And also thank you to those of you watching on the recording. And yeah, weāll let you know about next weekās proper scheduled Small is Beautiful.
Laura: As soon as we have something proper scheduled.
Aral: Yeah, yeah. I mean, once we have some guests. Yeah.
Laura: Yes.
Aral: All right. Awesome. So Iāve been Aral Balkan.
Laura: I have been Laura Kalbag.
Aral: And? This has been Small is Beautiful.
Laura: Yeah.
Aral: Yay. Take care, everyone.