@hzblj/kara-router 0.3.0 → 0.4.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # @hzblj/kara-router
2
2
 
3
+ ## 0.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`d14bdd3`](https://github.com/hzblj/kara-ui/commit/d14bdd37bede9fef80f4d3af4621ea5d60b2b16b)]:
8
+ - @hzblj/kara-native@0.4.1
9
+ - @hzblj/kara-theme@0.4.1
10
+ - @hzblj/kara-components@0.4.1
11
+
12
+ ## 0.4.0
13
+
14
+ ### Minor Changes
15
+
16
+ - [`6e7903a`](https://github.com/hzblj/kara-ui/commit/6e7903afa3d3442e04a48a6e24399f9f03559a03) Thanks [@hzblj](https://github.com/hzblj)! - Android polish, and a new `RnListItem`.
17
+
18
+ - `ContextMenu` on Android is a proper long-press menu: a ripple and the long-press haptic, then a Material dropdown where the finger is, with the actions' icons and the trigger highlighted while it is open. The ripple and highlight stay inside rounded corners.
19
+ - A pressable `HStack`, `VStack` or `ZStack` ripples across its whole shape, padding included; `ListItem` and `LabeledContent` take `px` so a row in a card can carry the card's padding inside its press area.
20
+ - `ListItem` keeps its chevron when the subtitle fills the line.
21
+ - `Tabs` take the theme's colours: on Android the bar, active indicator, icons, labels and ripple come from tokens instead of the wallpaper scheme; on iOS the selected item takes the accent.
22
+ - New `RnListItem`: `ListItem`'s row in the React Native tier, cheap to mount by the dozen, with a full-row ripple on Android and a highlight on iOS.
23
+
24
+ ### Patch Changes
25
+
26
+ - Updated dependencies [[`6e7903a`](https://github.com/hzblj/kara-ui/commit/6e7903afa3d3442e04a48a6e24399f9f03559a03)]:
27
+ - @hzblj/kara-components@0.4.0
28
+ - @hzblj/kara-theme@0.4.0
29
+ - @hzblj/kara-native@0.4.0
30
+
3
31
  ## 0.3.0
4
32
 
5
33
  ### Patch Changes
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
 
3
3
  import { iconResourceName } from '@hzblj/kara-native';
4
+ import { useAppTheme } from '@hzblj/kara-theme';
4
5
  import { NativeTabs } from 'expo-router/unstable-native-tabs';
5
- import { Children, isValidElement } from 'react';
6
+ import { Children, isValidElement, useMemo } from 'react';
7
+ import { Platform } from 'react-native';
6
8
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
9
  const {
8
10
  Icon,
@@ -48,13 +50,58 @@ const renderTrigger = ({
48
50
  })]
49
51
  }, name);
50
52
  };
53
+
54
+ /**
55
+ * The bar in the theme's colours. iOS keeps the system's glass bar and only takes the accent for the selected item;
56
+ * Android's Material bar would otherwise colour itself from the wallpaper's dynamic scheme, whatever the theme says —
57
+ * so the container, the active indicator, icons, labels and ripple are all set from tokens.
58
+ */
59
+ const useTabBarColors = () => {
60
+ const theme = useAppTheme();
61
+ return useMemo(() => {
62
+ const fontFamily = theme.typography.labelMedium.fontFamily;
63
+ const tintColor = theme.color('content.accent');
64
+ if (Platform.OS !== 'android') {
65
+ return {
66
+ labelStyle: {
67
+ fontFamily
68
+ },
69
+ tintColor
70
+ };
71
+ }
72
+ return {
73
+ backgroundColor: theme.color('surface.primary'),
74
+ iconColor: {
75
+ default: theme.color('content.secondary'),
76
+ selected: tintColor
77
+ },
78
+ indicatorColor: theme.color('fill.accent.base'),
79
+ labelStyle: {
80
+ default: {
81
+ color: theme.color('content.secondary'),
82
+ fontFamily
83
+ },
84
+ selected: {
85
+ color: theme.color('content.primary'),
86
+ fontFamily
87
+ }
88
+ },
89
+ rippleColor: theme.color('fill.accent.base'),
90
+ tintColor
91
+ };
92
+ }, [theme]);
93
+ };
51
94
  const TabsRoot = ({
52
95
  children,
53
96
  minimizeBehavior = 'never'
54
- }) => /*#__PURE__*/_jsx(NativeTabs, {
55
- minimizeBehavior: minimizeBehavior,
56
- children: Children.map(children, child => /*#__PURE__*/isValidElement(child) && child.type === TabsScreen ? renderTrigger(child.props) : child)
57
- });
97
+ }) => {
98
+ const colors = useTabBarColors();
99
+ return /*#__PURE__*/_jsx(NativeTabs, {
100
+ minimizeBehavior: minimizeBehavior,
101
+ ...colors,
102
+ children: Children.map(children, child => /*#__PURE__*/isValidElement(child) && child.type === TabsScreen ? renderTrigger(child.props) : child)
103
+ });
104
+ };
58
105
 
59
106
  /**
60
107
  * Native bottom tabs — a SwiftUI `TabView` on iOS and a Material navigation bar on Android, both
@@ -1 +1 @@
1
- {"version":3,"names":["iconResourceName","NativeTabs","Children","isValidElement","jsx","_jsx","jsxs","_jsxs","Icon","Label","Trigger","TabsScreen","renderTrigger","hidden","icon","name","selectedIcon","testID","title","asset","selected","undefined","children","drawable","default","xcasset","TabsRoot","minimizeBehavior","map","child","type","props","Tabs","Object","assign","Screen"],"sourceRoot":"../../../src","sources":["tabs/tabs.tsx"],"mappings":";;AAAA,SAAQA,gBAAgB,QAAO,oBAAoB;AACnD,SAAQC,UAAU,QAAO,kCAAkC;AAC3D,SAAQC,QAAQ,EAAEC,cAAc,QAAO,OAAO;AAAA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAI9C,MAAM;EAACC,IAAI;EAAEC;AAAK,CAAC,GAAGR,UAAU,CAACS,OAAO;;AAExC;AACA;AACA;AACA;AACA;AACA,MAAMC,UAAmC,GAAGA,CAAA,KAAM,IAAI;;AAEtD;AACA;AACA;AACA;AACA,MAAMC,aAAa,GAAGA,CAAC;EAACC,MAAM;EAAEC,IAAI;EAAEC,IAAI;EAAEC,YAAY;EAAEC,MAAM;EAAEC;AAAsB,CAAC,KAAK;EAC5F,MAAMC,KAAK,GAAGnB,gBAAgB,CAACc,IAAI,CAAC;EACpC,MAAMM,QAAQ,GAAGJ,YAAY,GAAGhB,gBAAgB,CAACgB,YAAY,CAAC,GAAGK,SAAS;EAE1E,oBACEd,KAAA,CAACN,UAAU,CAACS,OAAO;IAACG,MAAM,EAAEA,MAAO;IAAYE,IAAI,EAAEA,IAAK;IAACE,MAAM,EAAEA,MAAO;IAAAK,QAAA,gBACxEjB,IAAA,CAACG,IAAI;MACHe,QAAQ,EAAEH,QAAQ,GAAG;QAACI,OAAO,EAAEL,KAAK;QAAEC;MAAQ,CAAC,GAAGD,KAAM;MACxDM,OAAO,EAAEL,QAAQ,GAAG;QAACI,OAAO,EAAEL,KAAK;QAAEC;MAAQ,CAAC,GAAGD;IAAM,CACxD,CAAC,eACFd,IAAA,CAACI,KAAK;MAAAa,QAAA,EAAEJ;IAAK,CAAQ,CAAC;EAAA,GALiBH,IAMrB,CAAC;AAEzB,CAAC;AAED,MAAMW,QAAQ,GAAGA,CAAC;EAACJ,QAAQ;EAAEK,gBAAgB,GAAG;AAAkB,CAAC,kBACjEtB,IAAA,CAACJ,UAAU;EAAC0B,gBAAgB,EAAEA,gBAAiB;EAAAL,QAAA,EAC5CpB,QAAQ,CAAC0B,GAAG,CAACN,QAAQ,EAAEO,KAAK,IAC3B,aAAA1B,cAAc,CAAkB0B,KAAK,CAAC,IAAIA,KAAK,CAACC,IAAI,KAAKnB,UAAU,GAAGC,aAAa,CAACiB,KAAK,CAACE,KAAK,CAAC,GAAGF,KACrG;AAAC,CACS,CACb;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMG,IAAmB,GAAGC,MAAM,CAACC,MAAM,CAACR,QAAQ,EAAE;EAACS,MAAM,EAAExB;AAAU,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["iconResourceName","useAppTheme","NativeTabs","Children","isValidElement","useMemo","Platform","jsx","_jsx","jsxs","_jsxs","Icon","Label","Trigger","TabsScreen","renderTrigger","hidden","icon","name","selectedIcon","testID","title","asset","selected","undefined","children","drawable","default","xcasset","useTabBarColors","theme","fontFamily","typography","labelMedium","tintColor","color","OS","labelStyle","backgroundColor","iconColor","indicatorColor","rippleColor","TabsRoot","minimizeBehavior","colors","map","child","type","props","Tabs","Object","assign","Screen"],"sourceRoot":"../../../src","sources":["tabs/tabs.tsx"],"mappings":";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AAc,CAAkB0C,KAAK,CAAC,IAAIA,KAAK,CAACC,IAAI,KAAKjC,UAAU,GAAGC,aAAa,CAAC+B,KAAK,CAACE,KAAK,CAAC,GAAGF,KACrG;EAAC,CACS,CAAC;AAEjB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMG,IAAmB,GAAGC,MAAM,CAACC,MAAM,CAACT,QAAQ,EAAE;EAACU,MAAM,EAAEtC;AAAU,CAAC,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hzblj/kara-router",
3
- "version": "0.3.0",
3
+ "version": "0.4.1",
4
4
  "description": "Expo Router pieces of @hzblj/kara-ui: native tabs and a navigation theme mapped from the active kara theme.",
5
5
  "author": "Jan Blazej",
6
6
  "license": "MIT",
@@ -59,9 +59,9 @@
59
59
  ]
60
60
  },
61
61
  "dependencies": {
62
- "@hzblj/kara-components": "^0.3.0",
63
- "@hzblj/kara-native": "^0.3.0",
64
- "@hzblj/kara-theme": "^0.3.0"
62
+ "@hzblj/kara-components": "^0.4.1",
63
+ "@hzblj/kara-native": "^0.4.1",
64
+ "@hzblj/kara-theme": "^0.4.1"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "expo-router": "*",
package/src/tabs/tabs.tsx CHANGED
@@ -1,6 +1,8 @@
1
1
  import {iconResourceName} from '@hzblj/kara-native'
2
+ import {useAppTheme} from '@hzblj/kara-theme'
2
3
  import {NativeTabs} from 'expo-router/unstable-native-tabs'
3
- import {Children, isValidElement} from 'react'
4
+ import {Children, isValidElement, useMemo} from 'react'
5
+ import {Platform} from 'react-native'
4
6
 
5
7
  import type {TabsComponent, TabsProps, TabsScreenProps} from './tabs.types'
6
8
 
@@ -32,13 +34,47 @@ const renderTrigger = ({hidden, icon, name, selectedIcon, testID, title}: TabsSc
32
34
  )
33
35
  }
34
36
 
35
- const TabsRoot = ({children, minimizeBehavior = 'never'}: TabsProps) => (
36
- <NativeTabs minimizeBehavior={minimizeBehavior}>
37
- {Children.map(children, child =>
38
- isValidElement<TabsScreenProps>(child) && child.type === TabsScreen ? renderTrigger(child.props) : child
39
- )}
40
- </NativeTabs>
41
- )
37
+ /**
38
+ * The bar in the theme's colours. iOS keeps the system's glass bar and only takes the accent for the selected item;
39
+ * Android's Material bar would otherwise colour itself from the wallpaper's dynamic scheme, whatever the theme says —
40
+ * so the container, the active indicator, icons, labels and ripple are all set from tokens.
41
+ */
42
+ const useTabBarColors = () => {
43
+ const theme = useAppTheme()
44
+
45
+ return useMemo(() => {
46
+ const fontFamily = theme.typography.labelMedium.fontFamily
47
+ const tintColor = theme.color('content.accent')
48
+
49
+ if (Platform.OS !== 'android') {
50
+ return {labelStyle: {fontFamily}, tintColor}
51
+ }
52
+
53
+ return {
54
+ backgroundColor: theme.color('surface.primary'),
55
+ iconColor: {default: theme.color('content.secondary'), selected: tintColor},
56
+ indicatorColor: theme.color('fill.accent.base'),
57
+ labelStyle: {
58
+ default: {color: theme.color('content.secondary'), fontFamily},
59
+ selected: {color: theme.color('content.primary'), fontFamily},
60
+ },
61
+ rippleColor: theme.color('fill.accent.base'),
62
+ tintColor,
63
+ }
64
+ }, [theme])
65
+ }
66
+
67
+ const TabsRoot = ({children, minimizeBehavior = 'never'}: TabsProps) => {
68
+ const colors = useTabBarColors()
69
+
70
+ return (
71
+ <NativeTabs minimizeBehavior={minimizeBehavior} {...colors}>
72
+ {Children.map(children, child =>
73
+ isValidElement<TabsScreenProps>(child) && child.type === TabsScreen ? renderTrigger(child.props) : child
74
+ )}
75
+ </NativeTabs>
76
+ )
77
+ }
42
78
 
43
79
  /**
44
80
  * Native bottom tabs — a SwiftUI `TabView` on iOS and a Material navigation bar on Android, both