From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../application/src/components/ui/UIButton.css | 75 ++++++++++++++++++++++ .../application/src/components/ui/UIButton.js | 41 ++++++++++++ .../client/application/src/components/ui/moz.build | 7 ++ 3 files changed, 123 insertions(+) create mode 100644 devtools/client/application/src/components/ui/UIButton.css create mode 100644 devtools/client/application/src/components/ui/UIButton.js create mode 100644 devtools/client/application/src/components/ui/moz.build (limited to 'devtools/client/application/src/components/ui') diff --git a/devtools/client/application/src/components/ui/UIButton.css b/devtools/client/application/src/components/ui/UIButton.css new file mode 100644 index 0000000000..2d614e09b0 --- /dev/null +++ b/devtools/client/application/src/components/ui/UIButton.css @@ -0,0 +1,75 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* these styles com from Photon. Keep in mind that the "default" style is not used + in panels, and we should use the "micro" instead for default, stand-alone buttons. */ + +:root.theme-light { + --button-text-color: var(--grey-90); + --button-text-hover-color: var(--grey-90); + --button-text-pressed-color: var(--grey-90); + --button-background-color: var(--grey-90-a10); + --button-background-hover-color: var(--grey-90-a20); + --button-background-pressed-color: var(--grey-90-a30); +} + +:root.theme-dark { + --button-text-color: var(--grey-40); + --button-text-hover-color: var(--grey-30); + --button-text-pressed-color: var(--grey-30); + --button-background-color: var(--grey-10-a20); + --button-background-hover-color: var(--grey-10-a25); + --button-background-pressed-color: var(--grey-10-a30); +} + +.ui-button { + appearance: none; + transition: background-color 0.05s ease-in-out; + + margin: 0; + height: calc(var(--base-unit) * 6); + padding-inline-start: calc(2 * var(--base-unit)); + padding-inline-end: calc(2 * var(--base-unit)); + border: none; + border-radius: calc(var(--base-unit) / 2); + + color: var(--button-text-color); + background: var(--button-background-color); + font-size: var(--caption-10-font-size); +} + +.ui-button:-moz-focusring { + outline: none; +} +.ui-button::-moz-focus-inner { + border: 0; + padding: 0; +} + +.ui-button:enabled:hover { + background: var(--button-background-hover-color); + color: var(--button-text-hover-color); +} + +.ui-button:enabled:active { + background: var(--button-background-pressed-color); + color: var(--button-text-pressed-color); +} + +.ui-button:focus { + box-shadow: 0 0 0 1px var(--blue-50) inset, + 0 0 0 1px var(--blue-50), + 0 0 0 4px var(--blue-50-a30); +} + +.ui-button:disabled { + opacity: 0.4; +} + +/* Note: this "micro" variant here is not the same as the "micro" variant + in Photon docs (since we are using that one for our default size) */ +.ui-button--micro { + height: auto; + padding: calc(var(--base-unit) * 0.5) var(--base-unit); +} diff --git a/devtools/client/application/src/components/ui/UIButton.js b/devtools/client/application/src/components/ui/UIButton.js new file mode 100644 index 0000000000..bc3f297d85 --- /dev/null +++ b/devtools/client/application/src/components/ui/UIButton.js @@ -0,0 +1,41 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +const { + PureComponent, +} = require("resource://devtools/client/shared/vendor/react.js"); +const PropTypes = require("resource://devtools/client/shared/vendor/react-prop-types.js"); +const { + button, +} = require("resource://devtools/client/shared/vendor/react-dom-factories.js"); + +class UIButton extends PureComponent { + static get propTypes() { + return { + children: PropTypes.node, + className: PropTypes.string, + disabled: PropTypes.bool, + onClick: PropTypes.func, + size: PropTypes.oneOf(["micro"]), + }; + } + + render() { + const { className, disabled, onClick, size } = this.props; + const sizeClass = size ? `ui-button--${size}` : ""; + + return button( + { + className: `ui-button ${className || ""} ${sizeClass}`, + onClick, + disabled, + }, + this.props.children + ); + } +} + +module.exports = UIButton; diff --git a/devtools/client/application/src/components/ui/moz.build b/devtools/client/application/src/components/ui/moz.build new file mode 100644 index 0000000000..f62f66d310 --- /dev/null +++ b/devtools/client/application/src/components/ui/moz.build @@ -0,0 +1,7 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +DevToolsModules( + "UIButton.js", +) -- cgit v1.2.3