Make tables great again

Special for CSS-Minsk-JS conf, 20-09-2019

Put your cards on the table

Make tables great again

"Liberty Leading the People", Eugène Delacroix

Alena Batitskaya

@ABatickaya bit.ly/mtga-slides

Theories

"Do not use tables for layout. It’s a bad practice"

. . .

TABLES === EVIL

Summary

BRO NOT BRO

"Designers do not use tables in templates"

. . .

When I should use tables?

Table layout can be used to represent tabular relationships between data.

Tabular data

"Tables are difficult to adapt for mobiles"

. . .

See the Pen Tables. Ex2. overflow by Alena (@solarrust) on CodePen.

Horizontal scroll

See the Pen Tables. Ex3. Flex by Alena (@solarrust) on CodePen.

Cards are the new black

See the Pen Tables. Ex4. Flex + before by Alena (@solarrust) on CodePen.

Signs for cells

Tips

Do not use display: none

            thead {
            	position: absolute;
            	top: -9999px;
            	left: -9999px;
            }
        

"What about accessibility?"

. . .

VO key

Tab for navigation throw interactive elements.

VO key + ← ↑ ↓ → for navigation throw simple text and tables on the page.

VO key by default equal to Ctrl + Option.

Add role

        <table>
          <thead role="rowgroup">
            <tr role="row">
              <th role="columnheader">First name</th>
              ...
          </thead>
        </table>
      

Attribute role 🦸‍♂️

scope

Only necessary data

Talk with business / designer and find out is all this info so important for mobile users?

Hide unnecessary columns, but remember about aria-hidden="true"

"Why must I use table tag with all this tr-td stuff instead simple divs?"

. . .

"Why we should use all this semantic tags on sites instead of so comfortable divs?"

See the Pen Tables. Not table by Alena (@solarrust) on CodePen.

Experiment

Tables + React = 💔

react-rainbow-components = 💞

react-rainbow-components

Infinite loop

        while (true) {
          console.log("Developers avoid tables");
          console.log("Working groups don't pay enough attention");
          console.log("The standard staying in stagnation");
        }
      

Make tables great again

Thank you!

Alena Batitskaya

@ABatickaya bit.ly/mtga-slides