Skip to content
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.

Add :disabled rule to button css in Normalise/Reset #96

Closed
chris-pearce opened this issue Dec 16, 2016 · 3 comments
Closed

Add :disabled rule to button css in Normalise/Reset #96

chris-pearce opened this issue Dec 16, 2016 · 3 comments

Comments

@chris-pearce
Copy link
Contributor

In _normalise-reset.scss there's this declaration:

button,
html [type='button'], // [1]
[type='reset'],
[type='submit'] {
    /* stylelint-disable-next-line property-no-vendor-prefix */
    -webkit-appearance: button; // [3]
    cursor: pointer; // [2]
}

If any of the above elements are disabled via the disabled attr then the cursor: not-allowed; rule from this declaration won't work:

:disabled {
    cursor: not-allowed;
    pointer-events: none;
}

As it is overridden by the cursor: pointer; rule.

Either review these rules or add this:

&:disabled {
    cursor: not-allowed;
}

So:

button,
html [type='button'], // [1]
[type='reset'],
[type='submit'] {
    /* stylelint-disable-next-line property-no-vendor-prefix */
    -webkit-appearance: button; // [3]
    cursor: pointer; // [2]

    &:disabled {
         cursor: not-allowed;
    }
}
@chris-pearce
Copy link
Contributor Author

I think it's best to just ditch:

:disabled {
    cursor: not-allowed;
    pointer-events: none;
}

As in most cases it won't apply due to specificity.

@DaveOrDead thoughts?

@chris-pearce
Copy link
Contributor Author

I've added a new section to the CMDS settings as part of a CMDS PR:

/* 3. Disabled
   ========================================================================= */

/**
 * When an element is in a disabled state, typically applied via the `disabled`
 * attribute.
 */

$g-disabled-opacity: 0.6;

We could add another setting for cursor: not-allowed;? Or write it as a @mixin, e.g.:

@mixin disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

@chris-pearce
Copy link
Contributor Author

Closing, see #97.

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

No branches or pull requests

1 participant