UNPKG

formstone

Version:

Library of modular front end components.

308 lines (241 loc) 4.92 kB
/** * @component * @name Checkbox */ @import "imports/utils.less"; // Config @fs-checkbox-transition-duration: 0.15s; @fs-checkbox-transition-timing: ease; @fs-checkbox-marker-height-width: 20px; @fs-checkbox-flag-background: #666; // Disabled @fs-checkbox-disabled-opacity: 0.5; // Toggle @fs-checkbox-toggle-marker-background: #666; @fs-checkbox-toggle-marker-height: 40px; @fs-checkbox-toggle-marker-width: 100px; /** * @class * @name .fs-checkbox-element * @type element * @description Target elmement */ /** * @class * @name .fs-checkbox * @type element * @description Base widget class */ /** * @class * @name .fs-checkbox.fs-checkbox-checked * @type modifier * @description Indicates checked state */ /** * @class * @name .fs-checkbox.fs-checkbox-radio * @type modifier * @description Indicates radio interface */ /** * @class * @name .fs-checkbox.fs-checkbox-toggle * @type modifier * @description Indicates toggle interface */ /** * @class * @name .fs-checkbox.fs-checkbox-focus * @type modifier * @description Indicates focused state */ /** * @class * @name .fs-checkbox.fs-checkbox-disabled * @type modifier * @description Indicates disabled state */ .fs-checkbox { display: inline-block; vertical-align: middle; &, &:after, &:before, *, *:after, *:before { box-sizing: border-box; transition: none; user-select: none !important; } &-element_placeholder { display: none; visibility: hidden; } &-element { width: 110%; height: 110%; position: absolute; top: -5%; right: -5%; bottom: -5%; left: -5%; z-index: -1; background: transparent; border: 0; margin: 0; padding: 0; pointer-events: none; transition: none; opacity: 0; -webkit-appearance: none; } /** * @class * @name .fs-checkbox-label * @type element * @description Label element */ &-label { cursor: pointer; display: inline-block; line-height: @fs-checkbox-marker-height-width; overflow: hidden; user-select: none; } /** * @class * @name .fs-checkbox-marker * @type element * @description Marker element */ &-marker { position: relative; width: @fs-checkbox-marker-height-width; height: @fs-checkbox-marker-height-width; border: 1px solid; cursor: pointer; display: inline-block; // float: left; } /** * @class * @name .fs-checkbox-flag * @type element * @description Flag element */ &-flag { width: 100%; height: 100%; margin: 0; } &-flag:before { width: 5px; height: 10px; border: 2px solid; border-top: 0; border-left: 0; content: ''; display: block; margin: 3px 0 0 6px; transition: transform @fs-checkbox-transition-duration @fs-checkbox-transition-timing; transform: rotate(45deg) scale(0); } &-checked &-flag:before { transform: rotate(45deg) scale(1); } // Radio &-radio &-marker { position: relative; border-radius: 100%; } &-radio &-flag { width: (@fs-checkbox-marker-height-width / 2); height: (@fs-checkbox-marker-height-width / 2); position: absolute; top: 0; right: 0; bottom: 0; left: 0; background: @fs-checkbox-flag-background; border-radius: 100%; margin: auto; transform: scale(0); transition: transform @fs-checkbox-transition-duration @fs-checkbox-transition-timing; &:before { display: none; } } &-radio&-checked &-flag { transform: scale(1); &:before { display: none; } } // Disabled &-disabled { cursor: default; opacity: @fs-checkbox-disabled-opacity; } // &-disabled &-label { &-label&-disabled { cursor: default; } &-disabled &-marker { cursor: default; } // Toggle &-toggle { position: relative; } // &-toggle &-label { &-label&-toggle { line-height: @fs-checkbox-toggle-marker-height; } &-toggle &-marker { .fs_clearfix(); width: @fs-checkbox-toggle-marker-width; height: @fs-checkbox-toggle-marker-height; position: relative; } &-toggle &-flag { width: 50%; height: 100%; position: absolute; top: 0; left: 0; background: @fs-checkbox-toggle-marker-background; display: block; transition: left @fs-checkbox-transition-duration @fs-checkbox-transition-timing; } .no-touch &-toggle:hover &-flag:after { opacity: 1; } &-toggle&-checked &-flag { left: 50%; &:before { display: none; } } &-toggle&-disabled &-flag:after { display: none; } &-toggle &-state { width: 50%; display: block; line-height: @fs-checkbox-toggle-marker-height; margin: 0; text-align: center; &_on { float: left; } &_off { float: right; } } }