Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(checkbox): downstate activation #4368

Draft
wants to merge 1 commit into
base: delegate-controllers
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/checkbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"@spectrum-web-components/shared": "^0.42.2"
},
"devDependencies": {
"@spectrum-css/checkbox": "^8.1.5"
"@spectrum-css/checkbox": "^14.0.0-next.2"
},
"types": "./src/index.d.ts",
"customElements": "custom-elements.json",
Expand Down
4 changes: 4 additions & 0 deletions packages/checkbox/src/Checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ export class Checkbox extends SizedMixin(CheckboxMixin(SpectrumElement), {
delegatesFocus: true,
};

override spectrumConfig = {
downstate: ['spectrum-two'],
};

/**
* Disable this control. It will not receive focus or events
*/
Expand Down
87 changes: 52 additions & 35 deletions packages/checkbox/src/spectrum-checkbox.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ governing permissions and limitations under the License.
--spectrum-checkbox-control-color-disabled: var(
--spectrum-disabled-content-color
);
--spectrum-checkbox-checkmark-color: var(--spectrum-gray-75);
--spectrum-checkbox-checkmark-color: var(--spectrum-gray-50);
--spectrum-checkbox-invalid-color-default: var(
--spectrum-negative-color-900
);
Expand Down Expand Up @@ -76,7 +76,9 @@ governing permissions and limitations under the License.
--spectrum-checkbox-control-size: var(
--spectrum-checkbox-control-size-medium
);
--spectrum-checkbox-control-corner-radius: var(--spectrum-corner-radius-75);
--spectrum-checkbox-control-corner-radius: var(
--spectrum-corner-radius-small-size-medium
);
--spectrum-checkbox-focus-indicator-gap: var(
--spectrum-focus-indicator-gap
);
Expand All @@ -95,6 +97,9 @@ governing permissions and limitations under the License.
}

:host([size='s']) {
--spectrum-checkbox-control-corner-radius: var(
--spectrum-corner-radius-small-size-small
);
--spectrum-checkbox-font-size: var(--spectrum-font-size-75);
--spectrum-checkbox-height: var(--spectrum-component-height-75);
--spectrum-checkbox-control-size: var(
Expand All @@ -104,17 +109,10 @@ governing permissions and limitations under the License.
--spectrum-checkbox-text-to-control: var(--spectrum-text-to-control-75);
}

:host {
--spectrum-checkbox-font-size: var(--spectrum-font-size-100);
--spectrum-checkbox-height: var(--spectrum-component-height-100);
--spectrum-checkbox-control-size: var(
--spectrum-checkbox-control-size-medium
);
--spectrum-checkbox-top-to-text: var(--spectrum-component-top-to-text-100);
--spectrum-checkbox-text-to-control: var(--spectrum-text-to-control-100);
}

:host([size='l']) {
--spectrum-checkbox-control-corner-radius: var(
--spectrum-corner-radius-small-size-large
);
--spectrum-checkbox-font-size: var(--spectrum-font-size-200);
--spectrum-checkbox-height: var(--spectrum-component-height-200);
--spectrum-checkbox-control-size: var(
Expand All @@ -125,6 +123,9 @@ governing permissions and limitations under the License.
}

:host([size='xl']) {
--spectrum-checkbox-control-corner-radius: var(
--spectrum-corner-radius-small-size-extra-large
);
--spectrum-checkbox-font-size: var(--spectrum-font-size-300);
--spectrum-checkbox-height: var(--spectrum-component-height-300);
--spectrum-checkbox-control-size: var(
Expand Down Expand Up @@ -180,6 +181,13 @@ governing permissions and limitations under the License.
);
}

:host(:not([readonly]):is(:active, [active])) #input:not(:disabled) + #box {
transform: perspective(
var(--spectrum-component-size-minimum-perspective-down)
)
translateZ(var(--spectrum-component-size-difference-down));
}

:host([invalid][invalid]) #input:checked + #box:before,
:host([invalid][invalid]) #box:before {
border-color: var(
Expand Down Expand Up @@ -340,6 +348,36 @@ governing permissions and limitations under the License.
}

@media (hover: hover) {
:host(:hover) #box:before {
border-color: var(
--highcontrast-checkbox-highlight-color-hover,
var(
--mod-checkbox-control-color-hover,
var(--spectrum-checkbox-control-color-hover)
)
);
}

:host(:hover) #input:checked + #box:before {
border-color: var(
--highcontrast-checkbox-highlight-color-hover,
var(
--mod-checkbox-control-selected-color-hover,
var(--spectrum-checkbox-control-selected-color-hover)
)
);
}

:host(:hover) #label {
color: var(
--highcontrast-checkbox-content-color-hover,
var(
--mod-checkbox-content-color-hover,
var(--spectrum-checkbox-content-color-hover)
)
);
}

:host([invalid][invalid]:hover) #input:checked + #box:before,
:host([invalid][invalid]:hover) #box:before {
border-color: var(
Expand Down Expand Up @@ -383,27 +421,6 @@ governing permissions and limitations under the License.
);
}

:host(:hover) #box:before {
border-color: var(
--highcontrast-checkbox-highlight-color-hover,
var(
--mod-checkbox-control-color-hover,
var(--spectrum-checkbox-control-color-hover)
)
);
}

:host(:hover) #input:checked + #box:before {
border-color: var(
--highcontrast-checkbox-highlight-color-hover,
var(
--mod-checkbox-control-selected-color-hover,
var(--spectrum-checkbox-control-selected-color-hover)
)
);
}

:host(:hover) #label,
:host([invalid][invalid][indeterminate]:hover) #label {
color: var(
--highcontrast-checkbox-content-color-hover,
Expand Down Expand Up @@ -453,8 +470,8 @@ governing permissions and limitations under the License.
}
}

:host([emphasized]:is(:active, [active])[indeterminate]) #box:before,
:host([emphasized]:is(:active, [active])[indeterminate])
:host([emphasized][indeterminate]:is(:active, [active])) #box:before,
:host([emphasized][indeterminate]:is(:active, [active]))
#input:checked
+ #box:before,
:host([emphasized]:is(:active, [active])) #input:checked + #box:before {
Expand Down
19 changes: 18 additions & 1 deletion packages/checkbox/src/spectrum-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/

import { converterFor } from '../../../tasks/process-spectrum-utils.js';
import {
builder,
converterFor,
} from '../../../tasks/process-spectrum-utils.js';

const converter = converterFor('spectrum-Checkbox');

Expand Down Expand Up @@ -50,6 +53,20 @@ const config = {
],
],
},

hoist: true,
},
{
find: {
type: 'pseudo-class',
kind: 'not',
selectors: [[builder.class('is-readOnly')]],
},
replace: {
type: 'pseudo-class',
kind: 'not',
selectors: [[builder.attribute('readonly')]],
},
hoist: true,
},
converter.classToAttribute('is-readOnly', 'readonly'),
Expand Down
105 changes: 3 additions & 102 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5336,83 +5336,9 @@
resolved "https://registry.yarnpkg.com/@spectrum-css/vars/-/vars-9.0.8.tgz#6af3bcdace903b8461f5fcd4c9aa23e70128a456"
integrity sha512-rGfd7jqXOdR69bEjrRP58ynuIeJU0czPfwQvzhtCzg7jKVukV+efNHqrs086sC6xutB3W4TF71K/dZMr3oyTyg==

"@spectrum-web-components/base@^0.40.5":
version "0.40.5"
resolved "https://registry.yarnpkg.com/@spectrum-web-components/base/-/base-0.40.5.tgz#5e67bab5aa835d5ec3fa141abd14aaf5344ab9ee"
integrity sha512-lGvAkpWzaPuLBdKfFqQW5J4dBTsn8I9OxpfKoEifR9OdNEELJshNVs+9iZY+3AYx3s3Y2WRLnsGrxtWuNg595g==
dependencies:
lit "^2.5.0"

"@spectrum-web-components/button-group@^0.40.4-next.0":
version "0.40.5"
resolved "https://registry.yarnpkg.com/@spectrum-web-components/button-group/-/button-group-0.40.5.tgz#27a1ba1de8ceba2b09598126bd9769a470481f34"
integrity sha512-vgxgy4UcAOkiWQh/qN6Oex08Zxj24vP2uwUSBt4DqYqhKY/yupg8P+RhyQ0xfSQC70sTHyeGb1nxMZYus5qQUQ==
dependencies:
"@spectrum-web-components/base" "^0.40.5"
"@spectrum-web-components/button" "^0.40.5"

"@spectrum-web-components/button@^0.40.5":
version "0.40.5"
resolved "https://registry.yarnpkg.com/@spectrum-web-components/button/-/button-0.40.5.tgz#19424d1591390ca1b2255e4f6a3d60eacf4243bb"
integrity sha512-RWneeVltJgS3XWZlWd4cpzY6f8ZTaBRIJEy8RqPXeut90jb+VWZLdF/zhme8JpGK7hEfBcYGst31P06KebaIzw==
dependencies:
"@spectrum-web-components/base" "^0.40.5"
"@spectrum-web-components/clear-button" "^0.40.5"
"@spectrum-web-components/close-button" "^0.40.5"
"@spectrum-web-components/icon" "^0.40.5"
"@spectrum-web-components/icons-ui" "^0.40.5"
"@spectrum-web-components/shared" "^0.40.5"

"@spectrum-web-components/clear-button@^0.40.5":
version "0.40.5"
resolved "https://registry.yarnpkg.com/@spectrum-web-components/clear-button/-/clear-button-0.40.5.tgz#33c8d4ea19fc94bc4b2db6cb1076bd831011f855"
integrity sha512-5BzW9qGNYJj8O3WLaeVBVGt71bK60tpX6NTLQJWV/lcfSENMPEsO1ztziCrxJ5ENz8Y4hG20HTGlqamVfFmt6Q==
dependencies:
"@spectrum-web-components/base" "^0.40.5"

"@spectrum-web-components/close-button@^0.40.5":
version "0.40.5"
resolved "https://registry.yarnpkg.com/@spectrum-web-components/close-button/-/close-button-0.40.5.tgz#63a32235b7d6cc3c0a0e3ea6c19318d59174a781"
integrity sha512-ooSiUg1C7+GB6y2CoNusLmBor2huBSABG3Exo3BrQM2/viPf2BRUwnRj5ROh37VjdLCu3EUCpjxQ+n8nEcFKAA==
dependencies:
"@spectrum-web-components/base" "^0.40.5"

"@spectrum-web-components/eslint-plugin@file:./linters/eslint":
version "0.42.2"

"@spectrum-web-components/icon@^0.40.5":
version "0.40.5"
resolved "https://registry.yarnpkg.com/@spectrum-web-components/icon/-/icon-0.40.5.tgz#901013ae5f44fe27a19fcf02e0f8a43fe3e0df8a"
integrity sha512-uWzrsZshOfUSy33aep5/ww9ZVoL2asKSUnUAIz6DTH4cmPiT9kNdJXJr0Srru+Xy0DhjGIrpKRCMGLThfYB8Ow==
dependencies:
"@spectrum-web-components/base" "^0.40.5"
"@spectrum-web-components/iconset" "^0.40.5"

"@spectrum-web-components/icons-ui@^0.40.5":
version "0.40.5"
resolved "https://registry.yarnpkg.com/@spectrum-web-components/icons-ui/-/icons-ui-0.40.5.tgz#27b8e337fb162d090ea65ce7f1917a877bc1d226"
integrity sha512-bHYtTkFwAnz4jHWnmckOgvoEZPtskXfZXcM+us5J6kkOSfss4G6Npjra6+2Ud0OByGWD6KBilXbny3DBYLzAaA==
dependencies:
"@spectrum-web-components/base" "^0.40.5"
"@spectrum-web-components/icon" "^0.40.5"
"@spectrum-web-components/iconset" "^0.40.5"

"@spectrum-web-components/iconset@^0.40.5":
version "0.40.5"
resolved "https://registry.yarnpkg.com/@spectrum-web-components/iconset/-/iconset-0.40.5.tgz#1b202059e26d4cbb7607596d3c4f7985494b1f01"
integrity sha512-MY0VFg7yH/j3M7BIIROFR0LGFNj3WJs8VVbV47Req4nQTx6VPOIndnK8uhjFFMleXqEX8w/jVSqZgiD1PQ6w/w==
dependencies:
"@spectrum-web-components/base" "^0.40.5"

"@spectrum-web-components/shared@^0.40.5":
version "0.40.5"
resolved "https://registry.yarnpkg.com/@spectrum-web-components/shared/-/shared-0.40.5.tgz#d02311beed2b058f9d0930d7c2e4d2db58d6c09b"
integrity sha512-JyeBukaNmaacvl8Q0ezdbFRzBm/o/2uHmF7kOmWjElpe1KGH6RQ7JgRP9eiUW4ofMYKTOu5F7X5qqeTdvG9Z3g==
dependencies:
"@lit-labs/observers" "^2.0.0"
"@spectrum-web-components/base" "^0.40.5"
focus-visible "^5.1.0"

"@storybook/addon-a11y@^7.5.0":
version "7.6.17"
resolved "https://registry.yarnpkg.com/@storybook/addon-a11y/-/addon-a11y-7.6.17.tgz#77209c23b6908d52dc470a3318d76a0ffe9d47cb"
Expand Down Expand Up @@ -24354,7 +24280,7 @@ string-to-template-literal@^2.0.0:
resolved "https://registry.yarnpkg.com/string-to-template-literal/-/string-to-template-literal-2.0.0.tgz#0ce56bf42052d53049243e11dbf045b9ad687f9e"
integrity sha512-AbTUWHXMyoRlTFP9qe013dfGTFq1XbcBLUoLC7PcumbJewtUwNXCvnko5cH2gZkUFC7kD2Fwxiv4YIndkU0xHA==

"string-width-cjs@npm:string-width@^4.2.0":
"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand All @@ -24372,15 +24298,6 @@ string-width@^1.0.1:
is-fullwidth-code-point "^1.0.0"
strip-ansi "^3.0.0"

"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^2.1.0, string-width@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e"
Expand Down Expand Up @@ -24500,7 +24417,7 @@ stringify-object@^3.3.0:
is-obj "^1.0.1"
is-regexp "^1.0.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand Down Expand Up @@ -24533,13 +24450,6 @@ strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0:
dependencies:
ansi-regex "^4.1.0"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^7.0.0, strip-ansi@^7.0.1, strip-ansi@^7.1.0:
version "7.1.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
Expand Down Expand Up @@ -27225,7 +27135,7 @@ [email protected]:
"@types/trusted-types" "^2.0.2"
workbox-core "7.0.0"

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand Down Expand Up @@ -27260,15 +27170,6 @@ wrap-ansi@^6.2.0:
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^8.0.1:
version "8.0.1"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.0.1.tgz#2101e861777fec527d0ea90c57c6b03aac56a5b3"
Expand Down
Loading