@bitrise/bitkit 9.17.0-alpha-chakra.5 → 9.17.0

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bitrise/bitkit",
3
3
  "description": "Bitrise React component library",
4
- "version": "9.17.0-alpha-chakra.5",
4
+ "version": "9.17.0",
5
5
  "repository": "git@github.com:bitrise-io/bitkit.git",
6
6
  "main": "src/index.ts",
7
7
  "license": "UNLICENSED",
@@ -1,10 +1,49 @@
1
1
  const schemeColors = {
2
- default: { backgroundColor: 'inherit', color: 'inherit' },
3
- blue: { backgroundColor: 'blue.93', color: 'blue.40' },
4
- red: { backgroundColor: 'red.93', color: 'red.40' },
5
- green: { backgroundColor: 'green.95', color: 'green.50' },
6
- yellow: { backgroundColor: 'yellow.95', color: 'yellow.40' },
7
- purple: { backgroundColor: 'purple.95', color: 'purple.40' },
2
+ blue: {
3
+ color: 'blue.40',
4
+ _active: {
5
+ backgroundColor: 'blue.90',
6
+ },
7
+ _hover: {
8
+ backgroundColor: 'blue.93',
9
+ },
10
+ },
11
+ red: {
12
+ color: 'red.40',
13
+ _active: {
14
+ backgroundColor: 'red.90',
15
+ },
16
+ _hover: {
17
+ backgroundColor: 'red.93',
18
+ },
19
+ },
20
+ green: {
21
+ color: 'green.50',
22
+ _active: {
23
+ backgroundColor: 'green.90',
24
+ },
25
+ _hover: {
26
+ backgroundColor: 'green.93',
27
+ },
28
+ },
29
+ yellow: {
30
+ color: 'yellow.40',
31
+ _active: {
32
+ backgroundColor: 'yellow.90',
33
+ },
34
+ _hover: {
35
+ backgroundColor: 'yellow.93',
36
+ },
37
+ },
38
+ purple: {
39
+ color: 'purple.40',
40
+ _active: {
41
+ backgroundColor: 'purple.90',
42
+ },
43
+ _hover: {
44
+ backgroundColor: 'purple.93',
45
+ },
46
+ },
8
47
  };
9
48
 
10
49
  const ColorButtonTheme = {
@@ -13,8 +52,8 @@ const ColorButtonTheme = {
13
52
  display: 'inline-flex',
14
53
  alignItems: 'center',
15
54
  justifyContent: 'center',
16
- ...schemeColors[c || 'default'],
17
- _hover: schemeColors[c || 'default'],
55
+ backgroundColor: 'transparent',
56
+ ...schemeColors[c || 'blue'],
18
57
  };
19
58
  },
20
59
  };
@@ -34,6 +34,7 @@ const Badge = (props: BadgeProps) => {
34
34
 
35
35
  export interface TabProps extends ChakraTabProps {
36
36
  badge?: BadgeProps;
37
+ id: string;
37
38
  leftIconName?: TypeIconName;
38
39
  isDisabled?: boolean;
39
40
  rightIconName?: TypeIconName;
@@ -24,15 +24,19 @@ const badge = {
24
24
 
25
25
  export const WithDefaults: ComponentStory<typeof Tabs> = (props) => {
26
26
  return (
27
- <Tabs defaultIndex={1} variant="unstyled" {...props}>
27
+ <Tabs defaultTab="selected-as-default" {...props}>
28
28
  <TabList>
29
29
  <Tab id="basic">Basic</Tab>
30
30
  <Tab id="selected-as-default">Selected as default</Tab>
31
- <Tab leftIconName="Bell">With left icon</Tab>
31
+ <Tab id="with-left-icon" leftIconName="Bell">
32
+ With left icon
33
+ </Tab>
32
34
  <Tab id="with-badge" badge={badge}>
33
35
  With badge
34
36
  </Tab>
35
- <Tab isDisabled>Disabled</Tab>
37
+ <Tab id="disabled" isDisabled>
38
+ Disabled
39
+ </Tab>
36
40
  <Tab id="with-right-icon" rightIconName="ArrowForward">
37
41
  With right icon
38
42
  </Tab>
@@ -3,6 +3,7 @@ import { Tabs as ChakraTabs, TabsProps as ChakraTabsProps, forwardRef } from '@c
3
3
  import { useHistory } from '../../hooks';
4
4
 
5
5
  export interface TabsProps extends ChakraTabsProps {
6
+ defaultTab?: string;
6
7
  onChange?: (index: number, tabId?: string) => void;
7
8
  withHistory?: boolean;
8
9
  }
@@ -20,12 +21,13 @@ const getTabIds = (props: TabsProps) => {
20
21
  * An accessible tabs component that provides keyboard interactions and ARIA attributes described in the WAI-ARIA Tabs Design Pattern.
21
22
  */
22
23
  const Tabs = forwardRef<TabsProps, 'div'>((props, ref) => {
23
- const { defaultIndex = 0, onChange, withHistory, ...rest } = props;
24
+ const { defaultTab = '', onChange, withHistory, ...rest } = props;
25
+ const tabIds = getTabIds(props);
26
+ const defaultIndex = tabIds.indexOf(defaultTab) > -1 ? tabIds.indexOf(defaultTab) : 0;
27
+
24
28
  const { searchParams, replace } = useHistory();
25
29
  const [actualIndex, setActualIndex] = useState(defaultIndex);
26
30
 
27
- const tabIds = getTabIds(props);
28
-
29
31
  useEffect(() => {
30
32
  if (withHistory && searchParams.get('tab')) {
31
33
  const tabName = searchParams.get('tab') || '';