#dev 2021-06-06

2021-06-06 UTC
superkuh and [jacky] joined the channel
#
[jacky]
does anyone here play games on https://itch.io? I've been wanting to make something like bridgy for syncing game play info to one's site. It'll be easier via Itch versus Steam
reed, calebjasik, Abhas[m], batkin[m], nekr0z, gRegor, moose3333, doosboox8, rhiaro_, sknebel_, wagle_, deeden, sebbu, petermolnar, Kaja, Zegnat, capjamesg, hendursa1 and james joined the channel
#
capjamesg
Good morning IndieWeb!
#
capjamesg
I wanted to continue the discussion re: progressive enhancement. I have only just had the chance to make the change I wanted to make to my blog (not live yet). I now have a script tag which contains this text: https://gist.github.com/capjamesg/36f862b5bcd9bc1607497fc73dfa0e5a
#
capjamesg
In short, I: create a button element, set the right attribute / text content, and apprend it to the document.
#
capjamesg
On button click, the user is taken to a random interview on my site.
#
capjamesg
We discussed this on Friday and wanted to make sure I was on the right lines.
#
capjamesg
The alternative is removing the button completely, which I'm open to.
#
capjamesg
Now the button does not show up in Lynx, which is expected because it will only work with JS (otherwise, the button will not display on the user's page.
#
Loqi
Ok, I'll tell them that when I see them next
#
capjamesg
!tell Murray The <details> element does not play so nicely with Lynx. But then again, neither did the JS button.
gRegor joined the channel
#
capjamesg
The <details> element is a lot better actually.
#
capjamesg
It may not work in Lynx (:D) but it's good to know my quizzes can run with JS disabled.
[Murray] joined the channel
#
[Murray]
Oh interesting. I assume Lynx just falls back to _showing_ the hidden text? Does Lynx have any dynamic states (CSS animations, hover states etc.)? (I've never seen the point of Lynx, so never used it)
#
Loqi
[Murray]: capjamesg left you a message 1 hour, 27 minutes ago: The <details> element does not play so nicely with Lynx. But then again, neither did the JS button.
#
[Murray]
!tell capjamesg Looks good to me. You'll want to add the `type` attribute with a value of `button` to that i.e. `element.setAttribute("type", "button");` Otherwise, I imagine that the `#interview_button` element is just an empty `<div>` or something? If so, seems good to me πŸ™‚
#
Loqi
Ok, I'll tell them that when I see them next
#
capjamesg
Yeah. #interview_button goes to a <span> tag.
#
Loqi
capjamesg: [Murray] left you a message 8 minutes ago: Looks good to me. You'll want to add the `type` attribute with a value of `button` to that i.e. `element.setAttribute("type", "button");` Otherwise, I imagine that the `#interview_button` element is just an empty `<div>` or something? If so, seems good to me πŸ™‚
#
capjamesg
Thanks for the help!
#
capjamesg
On another note, I just finished watching this super interesting talk on accessibility design for gov.uk: https://www.youtube.com/watch?v=1cuZnBqQYKQ
#
capjamesg
Definitely very useful and they even talk about buttons that they have as semantic <a> tags for starting a form (where, as I have learned, a <button> tag would not be appropriate since no form action is being taken).
#
capjamesg
!Murray should I be using role='button' or type='button'?
jeremycherfas joined the channel
#
Zegnat
capjamesg: if it is a button element already, no need for a role="button" attribute
#
Zegnat
A button element, by default (if nothing set) has the type "submit". If your button is not submitting a form, it is better to set it to type="button". This means browsers still treat it as a button, but will know it does not need to find form actions to associate with it.
#
Zegnat
Hope that makes sense :) In general people add buttons only to submit forms, so that makes sense as a default. For JavaScript created buttons that trigger a custom action, set type="button" manually.
#
Zegnat
(The only other available type apart from "submit" and "button" is "reset", for clearing form fields within the some form as the button element.)
#
[Murray]
πŸ‘† this, and sorry for the confusion, I got mixed up the other day πŸ˜„
#
[Murray]
and I can thoroughly recommend everything the GovUK team have done around accessibility and user experience; their blog posts are a gold mine of usual information and genuine user research
#
[Murray]
not sure I've seen that exact video though, so thanks for sharing πŸ™‚
#
capjamesg
Yeah. gov.uk / the Government Digital Service is amazing in terms of accessibility / testing info.
#
capjamesg
Zegnat: I'm thinking about changing the button to an <a> tag.
#
[Murray]
Their design system is one of my go-to resources these days as well: https://design-system.service.gov.uk/components/details/
#
capjamesg
Or should I keep it as a button and use type=button?
#
capjamesg
Context reminder (not updated to include latest JS): https://jamesg.blog/interviews/
#
[Murray]
In terms of switching to an `<a>` over a `<button>` , I think Barnaby made some fair points the other day in favour of `<button>`
#
capjamesg
Yeah. I agree. I haven't encoutnered this question yet in any of my web work so I wanted to explroe it from all angles.
#
capjamesg
(Side question: what's the right way to "mention" someone in IRC? I know @XYZ is right in Slack but not sure about IRC)
#
[Murray]
given the new script you're using, I was tempted to say that it could just generate an `<a>` now but honestly, I think this is a rare case where both have some purpose
#
Zegnat
On IRC it would just be someone’s name.
#
capjamesg
Thanks, Zegnat.
#
capjamesg
Zegnat++
#
Loqi
Zegnat has 17 karma in this channel over the last year (63 in all channels)
#
capjamesg
Murray++
#
Loqi
Murray has 4 karma in this channel over the last year (7 in all channels)
#
capjamesg
I think that's the issue solved now re: using the right semantics, making the button accessible and progressively enhanced.
#
capjamesg
I'll push this change to the site now.
#
Zegnat
I think you can easily make cases for both button and a elements. And I am not sure the distinction really matters here. I think my personal preference would actually be the a-element. Because it triggers a navigation event, and browsers can show me where an a-element takes me, I can opt to open it in a new tab, etc. Lots of browser functionality you are not getting from buttons.
#
capjamesg
Yep. I agree. Is the type=button necessary then?
#
Zegnat
On an a-element? No
#
capjamesg
Excellent.
#
capjamesg
One final question :D
#
capjamesg
Do I need the draggable=true attribute here?
#
Zegnat
I don’t know why you would want any text elements on your site to be dragable?
#
capjamesg
Buttons are technically draggable so it might seem a bit jarring not to have that behavior on the <a> link.
#
capjamesg
gov.uk does this for their <a> buttons.
#
capjamesg
The text will be styled as a button.
#
capjamesg
My other buttons were not draggable actually. Interesting.
#
capjamesg
Maybe I'll leave this as is.
#
Zegnat
Oh, yeah, they are specifically turning a link into a button there. I am not sure why you would want that? If you are going to such lengths, just use a button element
#
Zegnat
In your case, I would switch to an a element only if you want it to be a link more than a button
#
capjamesg
So this link / button takes you to a random page on the site.
#
capjamesg
What is more appropriate: link or button?
#
Loqi
It looks like we don't have a page for "more appropriate: link or button" yet. Would you like to create it? (Or just say "more appropriate: link or button is ____", a sentence describing the term)
#
capjamesg
I don't think a button is as appropriate because there is no form action (i.e. submit).
#
Zegnat
I think that question can only be answered from the UX point of view. Do you want the user to feel like they have pressed a button to trigger an action, or do you want them to navigate to a different page like a link.
#
Zegnat
There are probably pros and cons for both scenarios
#
capjamesg
Good question. I want the element to be styled like a button because a link doesn't seem visually appropriate.
#
capjamesg
The behaviour of this link is different from all others in that it takes you to a random page on the site, rather than a specific one.
#
capjamesg
A button helps create a visual distinction.
#
capjamesg
(Sorry, a button style helps create a visual distinction.) But a button is associated more with a form semantically from what I've read.
#
Zegnat
Sure, but the semantics do not really matter for a user. Not really. And you can always patch up semantics with things like the role attribute (like what Gov UK is doing in the example you linked)
#
Zegnat
So what is the experience you want to create for the users. Because browsers will offer different options depending on whether you go with a button or a element.
#
Zegnat
Like opening in new tabs, etc.
#
Zegnat
I personally really prefer normal links for navigational actions. Specifically because my browser stays in control of the navigation between pages. So I would just offer a completely normal a element.
#
Zegnat
But I am also not a fan of surprises, so I realise the random button is not really aimed at me in the first place. I would probably have done it more like this: https://gist.github.com/Zegnat/ec461133a38801fe10d8242090f0a61b (you can run that directly in the browser console on the interviews page)
#
capjamesg
Interesting.
#
capjamesg
Your code more than anything illustrates that there is a better approach to this problem and you have identified it :)
#
capjamesg
I think your code gives the user a bit more predictability and a visual cue as to what to expect.
#
Zegnat
I am not sure it is better. There is definitely something to be said for random buttons too!
#
capjamesg
For the user, the goal is to give them a random interview. And I don't want to dig too much deeper into semantics :D
#
Zegnat
But for navigation on blogs and similar text media, I always come back to a keep-it-simple approach of anchor tags and clear signaling to users what will happen when they interact with it
#
capjamesg
Yeah. Ultimately, I want the blog to be as easy to navigate and understand as possible.
#
capjamesg
Your addition of the text "looking for a place to start?" was helpful because it gives the user context that is not present.
#
capjamesg
The button sort of sticks out in that it's not part of the logical flow of the page (there is no section specifically for the button, no title, no obvious progression between the text above and the button). A statement like "looking for a place to start?" solves this.
#
Zegnat
Just a rough idea, it could probably do with some tweaking.
#
Zegnat
Another interesting user experience might be to put a random article from the list at the top, with some sort of "randomly selected" label
#
Zegnat
But yeah, just my take on things :D Randomly selected article link up top.
#
Zegnat
The beauty of a personal website is that you can put any button on there that you like ;) Make it sparkle and jump all over the place if that is more your fancy
#
capjamesg
For sure. I think adding a random article to the list itself might be a bit odd in terms of the flow of the page but having one with a designated message before hand ("looking for a place to start?" or "new to my interviews? check out ...") is interesting.
#
capjamesg
I hope you are finding this as interesting as me Zegnat :D
#
Zegnat
I am half asleep, and this sort of discussion is exactly right for my current brain state, haha
#
capjamesg
Ah. I've just eaten lunch and am taking it slow today. I was away on a day trip yesterday and I'm always very tired the day after.
#
capjamesg
Yeah, this is defintely a UX question.
#
capjamesg
I know that Google has their "i'm feeling lucky" button.
#
Zegnat
yeah, that is definitely another interesting one. But there is actually a secondary actoin taken on a form field (the search field) so a button makes sense. It also cannot really give you the browser UI of a link, because the link is not yet known.
#
Zegnat
In your case, you can always know where you are sending the user. So you might as well tell them :)
capjamesg, barnaby, hendursaga and [Murray] joined the channel
#
[Murray]
Just to take it back to the semantics question: the best rule of thumb (as Zegnat hinted at) is to think about the action being taken. If you're navigating to a new page, use a link (`<a>`). If you're triggering any other kind of action, use a button. Style doesn't really matter (plenty of links look like buttons, plenty of buttons look like links; CSS/style is a different concern to semantics or functionality).
#
[Murray]
Now you have an interesting grey area, because the action is to first run a JS script that picks a random page, *and then* navigate to that page. You're doing both things, which is why either option becomes valid.
#
[Murray]
However, if you were to switch your code logic around for a second, I'd say an `<a>` becomes more semantically accurate. Instead of running the randomiser `onclick`, you could randomise the page url when the element is created and added to the DOM. If done that way, the actual element on the page will only ever do one thing: navigate. So I'd prefer an `<a>`. If you leave the randomising until the user clicks on the element, then I'd
#
[Murray]
prefer `<button>`. Like I said, bit of a grey area πŸ˜„
#
[Murray]
(of course, all moot if you remove it for a different UX 😁 )
gRegor, limeordl, buu_, KartikPrabhu, [Rose] and jamietanna joined the channel; barnaby left the channel
#
jamietanna
Back to the token expiry chat yesterday barnaby, GWG, Zegnat and sknebel
#
GWG
jamietanna: Yes?
#
jamietanna
I find 7 days is quite good for apps that don't support refresh tokens (as they're still not implemented widespread) but I'm planning on reducing the lifetime of tokens for clients that do get refresh tokens to be ~1 hour, to limit the risk of those tokens being leaked
#
jamietanna
For the case where we want infinite access, I'd prefer to have a "personal access token" style token that i.e GitHub allows, as a user-driven thing that can issue a token, which can then be included in i.e. some config file
#
jamietanna
For apps that can support refresh tokens, I'd prefer to go that route, as it's a bit safer
#
jamietanna
refresh tokens I've made last 30 days - if an app doesn't use it in that time they need me to re-consent to the access
#
Zegnat
I would have to do more reading on auth vs refresh tokens to be able to have a better opinion on length.
#
Zegnat
I wonder if 1 hour might be too short. I know of a handful of APIs with such shortlived tokens that people basically do not bother with them and always use the refresh token first for every request. At that point I am not sure it still gives any real security benefit?
#
GWG
Just no clients support refresh yet
#
Zegnat
Chicken and egg. I do not think there is a huge problem with servers finding a common ground on how to handle refresh tokens (issueing etc) first
#
GWG
For me, next IndieAuth project is expiring setting set on the auth screen
#
GWG
But a reference client to test against would motivate me on refresh
sparseMatrix joined the channel
#
sparseMatrix
0/
#
sparseMatrix
HEY y'all what's shakin'
#
sparseMatrix
Just stepped away from a big ol' foreign key exception to say hey as I haven't droppepd in for a bit : D
#
sparseMatrix
...and whatnot ; )
#
sparseMatrix
lfe happened, as they say (got some billable hours I can log), so not had as much time as when you last saw me
#
sparseMatrix
but just wanted to let y'all know I have been spending the time I have for such things on coding instead of 'blahblah'
#
sparseMatrix
and to that end, lemme get back to it, I'll see y'all again real soon now XD
jujudario, jeremycherfas, gerben and [tw2113_Slack_] joined the channel