Skip to content

0.4.0: media-specific class naming convention #29

@philipwalton

Description

@philipwalton

I'm wondering if you've given any thought to formalizing a naming convention for media specific classes. I've noticed you have media specific component classes in the grid-layout module, but I don't see any mention of naming recommendations in the docs.

I imagine most of the time a media specific class would conceptually fall into the realm of utility classes (e.g., something that sets display:none or converts inline-block to block when the viewport is less than 30em), but as your grids exemplify, they may also apply to component classes.

After giving it a bit of thought I think a named media query prefix makes the most sense. The convention would be:

.[mediaName-]ComponentName { }
.u-[mediaName-]utilityName { }

If you named your media query hand to refer to anything less than 30em, then you'd get something like this:

@media (max-width: 30em) {
  .u-hand-hidden {
    display: none !important;
  }  
  .u-hand-blockList {
    display: block !important;
  }
}

Thoughts?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions