mdgriffith / style-elements

Create styles that don't mysteriously break!
http://package.elm-lang.org/packages/mdgriffith/style-elements/latest
BSD 3-Clause "New" or "Revised" License
445 stars 49 forks source link

Question: is it possible to have some elements "grayed out"? #151

Closed akavel closed 6 years ago

akavel commented 6 years ago

The big picture of what I'm trying to do

Hi! I'd like to have a "grayed out overlay" effect over several elements of the layout (and making them disabled). I assume adding a "disabled" attribute will be easy, but I have no idea currently how to do the "grayed out overlay" effect with SE.

The effect I'm aiming for is similar to what happens when a modal dialog box is displayed on a phone. The elements "below" get grayed out.

What I did

No idea ATM how to even approach doing this in the framework of SE.

In a previous HTML-based prototype of my app, for the elements I wanted to gray-out, I applied the following CSS:

.grayed-out {
    /* Mostly NOP, but force child position:absolute elements to be contained
       see: https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#Identifying_the_containing_block
     */
    transform: translate(0,0);
}
.grayed-out:after {
    content: "";
    display: block;
    position: fixed;
    z-index: 1;
    top: 0; right: 0; bottom: 0; left: 0;
    background-color: rgba(85%,85%,85%, 75%);
}

— i.e., when I added a .grayed-out class to HTML elements, an extra "div" was generated over them, with gray color and 75% opacity.

Versions

akavel commented 6 years ago

Hmmm; I'm migrating my app to stylish-elephants (seems to be working much better), so I'll move my question there...