@canlooks/can-ui 0.0.36 → 0.0.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,10 +26,11 @@ const Button = ({ component: Component = 'button', color = 'primary', shape = 's
26
26
  };
27
27
  const actualPrefix = prefix ?? icon;
28
28
  const actualChildren = label ?? props.children;
29
+ const reverseTextColor = variant === 'filled' || variant === 'flatted' ? '#ffffff' : color;
29
30
  return ((0, jsx_runtime_1.jsxs)(Component, { ...props, css: (0, button_style_1.useStyle)({ color: color || 'primary' }), className: (0, utils_2.clsx)(button_style_1.classes.root, props.className), onPointerUp: onPointerUp, onClick: onClick, "data-variant": variant, "data-orientation": orientation, "data-shape": shape, "data-size": size, "data-loading": loading, "data-read-only": readOnly, children: [loading
30
31
  ? actualPrefix
31
- ? (0, jsx_runtime_1.jsx)(loadingIndicator_1.LoadingIndicator, { color: variant === 'filled' ? '#ffffff' : color })
32
- : (0, jsx_runtime_1.jsx)(transitionBase_1.Collapse, { orientation: "horizontal", in: true, children: (0, jsx_runtime_1.jsx)(loadingIndicator_1.LoadingIndicator, { color: variant === 'filled' ? '#ffffff' : color }) })
32
+ ? (0, jsx_runtime_1.jsx)(loadingIndicator_1.LoadingIndicator, { color: reverseTextColor })
33
+ : (0, jsx_runtime_1.jsx)(transitionBase_1.Collapse, { orientation: "horizontal", in: true, children: (0, jsx_runtime_1.jsx)(loadingIndicator_1.LoadingIndicator, { color: reverseTextColor }) })
33
34
  : actualPrefix, !!actualChildren &&
34
35
  (0, jsx_runtime_1.jsx)("div", { className: button_style_1.classes.content, children: actualChildren }), !!suffix &&
35
36
  (0, jsx_runtime_1.jsx)("div", { className: button_style_1.classes.suffix, children: suffix })] }));
@@ -16,9 +16,17 @@ function useStyle({ color }) {
16
16
  return (0, utils_1.useCss)(({ borderRadius, easing, spacing, text, gray }) => {
17
17
  const c = (0, color_1.default)(colorValue);
18
18
  const outlineColor = c.alpha(.4).string();
19
- const light = c.lighten(.1).hex();
20
- const lighter = c.lighten(.15).hex();
21
- const lightest = c.lighten(.2).hex();
19
+ let light, lighter, lightest;
20
+ if (c.hue()) {
21
+ light = c.lighten(.1).hex();
22
+ lighter = c.lighten(.15).hex();
23
+ lightest = c.lighten(.2).hex();
24
+ }
25
+ else {
26
+ light = c.lightness(20).hex();
27
+ lighter = c.lightness(30).hex();
28
+ lightest = c.lightness(60).hex();
29
+ }
22
30
  const darkC = c.darken(.1);
23
31
  const dark = darkC.hex();
24
32
  const defaultStyle = (0, react_1.css) `
@@ -46,5 +46,5 @@ exports.ToggleButton = (({ variant = 'filled', size, color = 'primary', disabled
46
46
  return c;
47
47
  });
48
48
  };
49
- return ((0, jsx_runtime_1.jsx)(flex_1.Flex, { compact: true, ...props, className: (0, utils_1.clsx)(toggleButton_style_1.classes.root, props.className), children: renderItems() }));
49
+ return ((0, jsx_runtime_1.jsx)(flex_1.Flex, { compact: true, ...props, css: toggleButton_style_1.style, className: (0, utils_1.clsx)(toggleButton_style_1.classes.root, props.className), children: renderItems() }));
50
50
  });
@@ -1,3 +1,4 @@
1
1
  export declare const classes: {
2
2
  root: string;
3
3
  };
4
+ export declare const style: () => import("@emotion/react").SerializedStyles;
@@ -1,5 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.classes = void 0;
3
+ exports.style = exports.classes = void 0;
4
4
  const utils_1 = require("../../utils");
5
+ const react_1 = require("@emotion/react");
6
+ const button_style_1 = require("../button/button.style");
5
7
  exports.classes = (0, utils_1.defineInnerClasses)('buttonGroup');
8
+ exports.style = (0, utils_1.defineCss)(({ divider }) => (0, react_1.css) `
9
+ .${button_style_1.classes.root}[data-variant=outlined] {
10
+ border-color: ${divider};
11
+
12
+ &:not(:disabled):not([data-read-only=true]):not([data-loading=true]) {
13
+ &:hover {
14
+ color: inherit;
15
+ }
16
+ }
17
+ }
18
+ `);
@@ -23,10 +23,11 @@ export const Button = ({ component: Component = 'button', color = 'primary', sha
23
23
  };
24
24
  const actualPrefix = prefix ?? icon;
25
25
  const actualChildren = label ?? props.children;
26
+ const reverseTextColor = variant === 'filled' || variant === 'flatted' ? '#ffffff' : color;
26
27
  return (_jsxs(Component, { ...props, css: useStyle({ color: color || 'primary' }), className: clsx(classes.root, props.className), onPointerUp: onPointerUp, onClick: onClick, "data-variant": variant, "data-orientation": orientation, "data-shape": shape, "data-size": size, "data-loading": loading, "data-read-only": readOnly, children: [loading
27
28
  ? actualPrefix
28
- ? _jsx(LoadingIndicator, { color: variant === 'filled' ? '#ffffff' : color })
29
- : _jsx(Collapse, { orientation: "horizontal", in: true, children: _jsx(LoadingIndicator, { color: variant === 'filled' ? '#ffffff' : color }) })
29
+ ? _jsx(LoadingIndicator, { color: reverseTextColor })
30
+ : _jsx(Collapse, { orientation: "horizontal", in: true, children: _jsx(LoadingIndicator, { color: reverseTextColor }) })
30
31
  : actualPrefix, !!actualChildren &&
31
32
  _jsx("div", { className: classes.content, children: actualChildren }), !!suffix &&
32
33
  _jsx("div", { className: classes.suffix, children: suffix })] }));
@@ -11,9 +11,17 @@ export function useStyle({ color }) {
11
11
  return useCss(({ borderRadius, easing, spacing, text, gray }) => {
12
12
  const c = Color(colorValue);
13
13
  const outlineColor = c.alpha(.4).string();
14
- const light = c.lighten(.1).hex();
15
- const lighter = c.lighten(.15).hex();
16
- const lightest = c.lighten(.2).hex();
14
+ let light, lighter, lightest;
15
+ if (c.hue()) {
16
+ light = c.lighten(.1).hex();
17
+ lighter = c.lighten(.15).hex();
18
+ lightest = c.lighten(.2).hex();
19
+ }
20
+ else {
21
+ light = c.lightness(20).hex();
22
+ lighter = c.lightness(30).hex();
23
+ lightest = c.lightness(60).hex();
24
+ }
17
25
  const darkC = c.darken(.1);
18
26
  const dark = darkC.hex();
19
27
  const defaultStyle = css `
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
2
  import { Children, cloneElement, isValidElement } from 'react';
3
3
  import { Flex } from '../flex';
4
4
  import { clsx, isSelected } from '../../utils';
5
- import { classes } from './toggleButton.style';
5
+ import { classes, style } from './toggleButton.style';
6
6
  import { Button } from '../button';
7
7
  import { useShallowSelection } from '../selectionContext';
8
8
  export const ToggleButton = (({ variant = 'filled', size, color = 'primary', disabled, readOnly, items, primaryKey = 'value', multiple, defaultValue, value, onChange, ...props }) => {
@@ -43,5 +43,5 @@ export const ToggleButton = (({ variant = 'filled', size, color = 'primary', dis
43
43
  return c;
44
44
  });
45
45
  };
46
- return (_jsx(Flex, { compact: true, ...props, className: clsx(classes.root, props.className), children: renderItems() }));
46
+ return (_jsx(Flex, { compact: true, ...props, css: style, className: clsx(classes.root, props.className), children: renderItems() }));
47
47
  });
@@ -1,3 +1,4 @@
1
1
  export declare const classes: {
2
2
  root: string;
3
3
  };
4
+ export declare const style: () => import("@emotion/react").SerializedStyles;
@@ -1,2 +1,15 @@
1
- import { defineInnerClasses } from '../../utils';
1
+ import { defineCss, defineInnerClasses } from '../../utils';
2
+ import { css } from '@emotion/react';
3
+ import { classes as buttonClasses } from '../button/button.style';
2
4
  export const classes = defineInnerClasses('buttonGroup');
5
+ export const style = defineCss(({ divider }) => css `
6
+ .${buttonClasses.root}[data-variant=outlined] {
7
+ border-color: ${divider};
8
+
9
+ &:not(:disabled):not([data-read-only=true]):not([data-loading=true]) {
10
+ &:hover {
11
+ color: inherit;
12
+ }
13
+ }
14
+ }
15
+ `);