Skip to content

Commit

Permalink
feat(switch): update spectrum css input
Browse files Browse the repository at this point in the history
  • Loading branch information
Westbrook Johnson authored and Westbrook committed Jan 6, 2021
1 parent d875a0c commit 1d2ce17
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/switch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ visual prominence that is optimal for forms, settings, etc. where the switches
need to be noticed.

```html
<sp-switch checked quiet>Web component</sp-switch>
<sp-switch checked emphasized>Web component</sp-switch>
```

## State
Expand Down
2 changes: 1 addition & 1 deletion packages/switch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"author": "",
"license": "Apache-2.0",
"devDependencies": {
"@spectrum-css/switch": "^1.0.0-beta.2"
"@spectrum-css/switch": "^1.0.0-beta.3"
},
"dependencies": {
"@spectrum-web-components/base": "^0.1.3",
Expand Down
4 changes: 0 additions & 4 deletions packages/switch/src/spectrum-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ const config = {
name: 'label',
},
],
exclude: [
/* deprecated */
/spectrum-Switch--ab/,
],
},
],
};
Expand Down
33 changes: 33 additions & 0 deletions packages/switch/src/switch.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,36 @@ governing permissions and limitations under the License.
*/

@import './spectrum-switch.css';

/**
* Work around the realities in https://github.com/adobe/spectrum-css/issues/1089
* while full t-shirt sizing is being developed at the Spectrum CSS level.
*/
:host {
--spectrum-switch-label-margin-top: var(
--spectrum-global-dimension-size-65,
5px
);
--spectrum-switch-track-width: var(--spectrum-global-dimension-size-325);
--spectrum-switch-handle-border-radius: 50%;
}

:host([dir='ltr'][checked]) #input + #switch:before {
/* [dir=ltr] .spectrum-Switch-input:checked+.spectrum-Switch-switch:before */
transform: translateX(
calc(
var(--spectrum-switch-track-width) -
var(--spectrum-switch-handle-size)
)
);
}

:host([dir='rtl'][checked]) #input + #switch:before {
/* [dir=rtl] .spectrum-Switch-input:checked+.spectrum-Switch-switch:before */
transform: translateX(
calc(
var(--spectrum-switch-handle-size) -
var(--spectrum-switch-track-width)
)
);
}

0 comments on commit 1d2ce17

Please # to comment.