Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve link focus styles #89

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Improve link focus styles #89

wants to merge 14 commits into from

Conversation

Steellow
Copy link
Member

@Steellow Steellow commented Oct 18, 2021

Fixes #70

@Steellow Steellow requested a review from mtsknn October 18, 2021 12:35
@netlify
Copy link

netlify bot commented Oct 18, 2021

❌ Deploy Preview for koodikrapula failed.

🔨 Explore the source changes: 2b2c335

🔍 Inspect the deploy log: https://app.netlify.com/sites/koodikrapula/deploys/61780c70e88b070008ff5e0c

src/js/utils/markdownIt.js Outdated Show resolved Hide resolved
md.use(markdownItLinkAttributes, {
attrs: {
class:
'underline text-red(hover:600 active:700) focus-visible:(outline-none ring-2 ring-blue-300 border-transparent)',
Copy link
Member

@mtsknn mtsknn Oct 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be good to export these classes from Link.js (e.g. as linkClasses) so the classes are not duplicated between two files (Link.js and here).

An alternative would be to add some preflight styles to twind.config.js, something like:

preflight: {
  ':focus-visible': 'outline-none ring-2 ring-blue-300',
}

This style would apply to all focusable elements, not just links (<a>), so this could be better.

Btw we already have preflight styles for .prose a:hover and .prose a:focus (the .prose class comes from https://github.com/tw-in-js/typography), so no need to specify these classes in markdownIt.js: underline text-red(hover:600 active:700).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea 👍🏽 I left text-red classes to linkClasses const so it can be used anywhere. No need to add text-red classes to Link component seperately now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, good idea. 👍 These might now be unnecessary in twind.config.js (npm start must be restarted after modifying this file):

'.prose a:hover': apply('text-red-600'),
'.prose a:active': apply('text-red-700'),

Remove these if you want extra points. 😀

Copy link
Member

@mtsknn mtsknn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wth the build's failing!!1

src/js/components/Link.js Outdated Show resolved Hide resolved
@@ -40,6 +40,8 @@ module.exports = {
// because sometimes it's clearer than template strings
'prefer-template': 'off',

'no-unused-vars': 'warn',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: move this before 'no-use-before-define' so that the built-in rules are sorted alphabetically. 😂

"preact": "^10.5.13",
"preact-render-to-string": "^5.1.19",
"prettier": "2.3.2",
"react": "^17.0.2",
"twind": "^0.16.16"
},
"devDependencies": {
"@types/eslint": "^7.2.13"
"@types/eslint": "^7.2.13",
"eslint-plugin-simple-import-sort": "^7.0.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ESLint is run in Netlify deploy preview builds, and Netlify installs only dependencies (not devDependencies), so this must be moved back to dependencies. The build is currently failing because of this.

@@ -1,6 +1,7 @@
import { ExternalLinkIcon } from '@heroicons/react/solid'
import { html } from 'htm/preact'
import { apply, tw } from 'twind'
import { linkClasses } from '../utils/const'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { linkClasses } from '../utils/const'
export const linkClasses =
'underline text-red(hover:600 active:700) focus-visible:(outline-none ring(2 blue-300 offset-2))'

I would move this here because the classes are closely related to the Link component. Wdyt?

See also Locality of Behavior / Co-location. 😜

@mtsknn mtsknn changed the title 70 focus styles Improve link focus styles Oct 27, 2021
@mtsknn mtsknn self-requested a review October 27, 2021 08:15
Copy link
Member

@mtsknn mtsknn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build is failing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement nicer focus styles
2 participants