Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
How to write HTML at Dude.
On this page you'll find examples on how to write HTML according to Dude Coding Standards.
Welcome to the Dude Coding Standards (DCS) documentation by Finnish digital agency Dude, locally known literally as Digitoimisto Dude Oy.
You are browsing the technical Coding Standards handbook of Dude, the Finnish digital agency. This handbook is supposed to be helpful for both internal and external members of Dude. It consists of best practices in programming at Dude.
We are committed to keep this handbook under continuous development. If we notice issues in our tech, workflow, DevOps or anything related, we will improve on those areas. If you have any suggestions to this handbook, please send them to roni@dude.fi. Thanks!
Our area of operation is currently Finland, but as we are a part for active WordPress community, actively publishing our tools and ways with open source licenses and using English as a development language, hence this documentation landing page is in English as well.
WIP-note for staff: This Space is meant for public Coding Standards documentation only that should be visible for everyone online. Everything else in tech should be located in Internal Development Docs or .
is a shortened name of a Finnish boutique web design agency formed in 2013 in Jyväskylä, Finland. Our main product is customized WordPress websites, weshops and web services for companies.
How to create an accessible search form.
In here we have a fully functional search form for visual people. However, labels contain text and inputs that are not accessible programmatically. Also in this example icon has been created by adding SVG inside label and hidden submit via styles. This means the user with keyboard or assistive devices can't use the form. Also for attribute is completely missing. Role is defined incorrectly for the form itself, that's wrong because form has role="form" explicitly built-in already.
This example has the proper form according to . The search bar label is hidden visually with screen-reader-text class because in the layout it's not visible and normally seeing people still see the actual placeholder. The assistive devices will still read the label.
Under this doc you'll find out how you should do the markup of HTML elements.
In this example we have an empty hyperlink element that is still readable with screen reader devices. It tells the blind nothing so it's a huge accessibility issue. And that's not all, the element is also not browsable via keyboard because its styles fill up the whole column.
This example ignores the global link from screen readers and keyboards so that it serves only for seeing users. For assistive devices we use a normal link in title
In PHP development we use the official and WordPress Theme Coding Standards with some exceptions. You can see the exceptions in our but besides this we have some project-based rules.
We use the word "heading" instead of "title".
Sometimes headings don't need any class. So do not add classes without reason. No class needed in following cases:
If the heading follow the generic typographic styles
If the heading style is used only once
If there is no component or classes in CSS
Or prefix. Whatever you like to call them.
Please note: Class names should go hand in hand with .
This markup actually links the smaller prefix title to the main title. Remember to always use unique id for this in both aria-describedby
and id
attribute values. This can be easily achieved with WordPress's function.
If for some reason you need to use something that has been disallowed in phpcs.xml you should have good arguments in favor to it. You should comment the change accordingly:
With phpcbf it's quick to fix the most common errors that are not right accoring to your project phpcs.xml.
You should always comment your code as thorough as possible. For indentation we use to char space. Always use the latest .editorconfig:
Please also see the installation in or on . Your editors should lint automatically after installing these tools.
Our custom blocks are named:
Items inside block:
These can be columns, upsells, grids, masonries, social media walls, logowalls, etc.
Site-header and site-footer follow the WordPress guidelines:
Content width container is always:
Something "smaller" like text:
Other general wrappers:
We use heading
instead of title
.
Defined in _button.scss component.
The Guidelines are based on stylelint standards we have defined. Our stylelint config extends stylelint-config-standard
and stylelint-config-recommended-scss
. View the full .stylelintrc here:
Defined format:
We don't need separate breakpoint-specific variables.
We can just redefine the values of each original custom property within the scope of each media/container query. Which would work well if the nav mobile and desktop partials are ever consolidated in the future.
Dude uses SCSS and modern CSS for styles. Our way of doing cascading style sheets is our own hybrid that is based on and the style guide used by by WordPress. Practically this brings us the is-*
and has-*
naming conventions in selectors.
First we define the main fonts and then the context where we are using the font families.
Always check out your .stylelintrc
for the latest rules. Aim for readable CSS. Use the "inception rule", do not go too deep.
Too much speficity. Hard to maintain.
We are just styling the link here so no need for extra nesting and specificity. Just cut to the chase and define with class.
If it's going to be a global style, you can even simplify it and add it outside the scope. Remember to choose classes wisely.
Working with SVGs, the Dude way
currentColor
If you need to change the color of the SVG with CSS, plug the currentColor
value into the stroke
and/or fill
attributes. With currentColor
, the color applied to the SVG will be the same color
that’s already declared in the SVG’s parent element. You can also change the color to something else by adding a color
declaration directly to an SVG ruleset.
By default, the Gutenberg block icons in the WP dashboard will contain a black fill. Follow these steps to nuke that annoying fill:
Add a class name directly to the SVG. Ex: class="gutenberg-icon"
In the _colors.scss
file, apply a color value (most likely, white) to the SVG, like so:
Here’s the SVG’s code:
Add your new SVG file to the nav-walker.php
file:
Now let’s hide that path. Add these rulesets and declarations to your theme’s nav files:
In _nav-desktop.scss
In _nav-mobile.scss
When working with decorative SVG icons, add the aria-hidden="true"
attribute to your SVG file.
Manually remove clipPaths from the file. This includes <g>
, <clipPath>
, and <def>
tags, plus any additional child elements wrapped in <def>
tags. Here’s a visual example where the tags to remove are commented out:
Copy the viewBox
attribute and its values.
Paste the viewBox
attribute back into the file after the height
attribute.
If the SVG is missing the viewbox
attribute and its values, the SVG will be broken and the front-end Dude on the project will wonder why their pretty SVG styles aren’t showing up in the browser.
Minimize the contents of the file with the in VSCode.