@hero-design/rn 8.27.0 → 8.27.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/.turbo/turbo-build.log +1 -1
- package/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/es/index.js +306 -242
- package/lib/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/lib/index.js +306 -242
- package/package.json +5 -5
- package/src/components/Icon/HeroIcon/glyphMap.json +1 -1
- package/src/components/Icon/IconList.ts +1 -0
- package/src/components/Toolbar/StyledToolbar.tsx +23 -2
- package/src/components/Toolbar/ToolbarGroup.tsx +3 -4
- package/src/components/Toolbar/ToolbarItem.tsx +75 -19
- package/src/components/Toolbar/__tests__/ToolbarItem.spec.tsx +39 -22
- package/src/components/Toolbar/__tests__/__snapshots__/ToolbarGroup.spec.tsx.snap +318 -186
- package/src/components/Toolbar/__tests__/__snapshots__/ToolbarItem.spec.tsx.snap +280 -135
- package/src/components/Typography/Text/StyledText.tsx +2 -1
- package/src/components/Typography/Text/index.tsx +2 -1
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +11 -1
- package/src/theme/components/toolbar.ts +14 -2
- package/src/theme/components/typography.ts +1 -0
- package/types/components/Icon/IconList.d.ts +1 -1
- package/types/components/Icon/index.d.ts +1 -1
- package/types/components/Icon/utils.d.ts +1 -1
- package/types/components/Toolbar/StyledToolbar.d.ts +11 -1
- package/types/components/Typography/Text/StyledText.d.ts +1 -1
- package/types/components/Typography/Text/index.d.ts +1 -1
- package/types/theme/components/toolbar.d.ts +9 -0
- package/types/theme/components/typography.d.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn",
|
|
3
|
-
"version": "8.27.
|
|
3
|
+
"version": "8.27.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@emotion/native": "^11.9.3",
|
|
23
23
|
"@emotion/react": "^11.9.3",
|
|
24
|
-
"@hero-design/colors": "8.27.
|
|
24
|
+
"@hero-design/colors": "8.27.1",
|
|
25
25
|
"date-fns": "^2.16.1",
|
|
26
26
|
"events": "^3.2.0",
|
|
27
27
|
"hero-editor": "^1.9.21"
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@babel/preset-typescript": "^7.17.12",
|
|
46
46
|
"@babel/runtime": "^7.18.9",
|
|
47
47
|
"@emotion/jest": "^11.9.3",
|
|
48
|
-
"@hero-design/eslint-plugin": "8.27.
|
|
48
|
+
"@hero-design/eslint-plugin": "8.27.1",
|
|
49
49
|
"@react-native-community/datetimepicker": "^3.5.2",
|
|
50
50
|
"@react-native-community/slider": "4.1.12",
|
|
51
51
|
"@rollup/plugin-babel": "^5.3.1",
|
|
@@ -61,10 +61,10 @@
|
|
|
61
61
|
"@types/react-native": "^0.67.7",
|
|
62
62
|
"@types/react-native-vector-icons": "^6.4.10",
|
|
63
63
|
"babel-plugin-inline-import": "^3.0.0",
|
|
64
|
-
"eslint-config-hd": "8.27.
|
|
64
|
+
"eslint-config-hd": "8.27.1",
|
|
65
65
|
"eslint-plugin-import": "^2.27.5",
|
|
66
66
|
"jest": "^27.3.1",
|
|
67
|
-
"prettier-config-hd": "8.27.
|
|
67
|
+
"prettier-config-hd": "8.27.1",
|
|
68
68
|
"react": "18.0.0",
|
|
69
69
|
"react-native": "0.69.7",
|
|
70
70
|
"react-native-gesture-handler": "~2.1.0",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"activate":59000,"add-emoji":59001,"add-person":59002,"adjustment":59003,"alignment":59004,"antenna":59005,"archive":59006,"assignment-warning":59007,"bank":59008,"bell":59009,"billing":59010,"bolt":59011,"bookmark-added":59012,"bookmark":59013,"box-check":59014,"box":59015,"bpay":59016,"buildings":59017,"cake":59018,"calendar-clock":59019,"calendar":59020,"candy-box-menu":59021,"caret-down-small":59022,"caret-down":59023,"caret-left-small":59024,"caret-left":59025,"caret-right-small":59026,"caret-right":59027,"caret-up-small":59028,"caret-up":59029,"check-radio":59030,"circle-add":59031,"circle-cancel":59032,"circle-check":59033,"circle-down":59034,"circle-info":59035,"circle-left":59036,"circle-ok":59037,"circle-pencil":59038,"circle-question":59039,"circle-remove":59040,"circle-right":59041,"circle-up":59042,"circle-warning":59043,"clock-3":59044,"clock":59045,"cloud-download":59046,"cloud-upload":59047,"cog":59048,"coin":59049,"contacts":59050,"credit-card":59051,"diamond":59052,"direction-arrows":59053,"directory":59054,"document":59055,"dollar-coin-shine":59056,"double-buildings":59057,"edit-template":59058,"envelope":59059,"exclude":59060,"expense":59061,"eye-circle":59062,"eye-invisible":59063,"eye":59064,"face-meh":59065,"face-sad":59066,"face-smiley":59067,"feed":59068,"feedbacks":59069,"file-certified":59070,"file-clone":59071,"file-copy":59072,"file-csv":59073,"file-dispose":59074,"file-doc":59075,"file-excel":59076,"file-export":59077,"file-lock":59078,"file-pdf":59079,"file-powerpoint":59080,"file-search":59081,"file-secured":59082,"file-sheets":59083,"file-slide":59084,"file-verified":59085,"file-word":59086,"file":59087,"filter":59088,"folder-user":59089,"folder":59090,"format-bold":59091,"format-heading1":59092,"format-heading2":59093,"format-italic":59094,"format-list-bulleted":59095,"format-list-numbered":59096,"format-underlined":59097,"funnel-filter":59098,"global-dollar":59099,"globe":59100,"graduation-cap":59101,"graph":59102,"happy-sun":59103,"health-bag":59104,"heart":59105,"home":59106,"image":59107,"import":59108,"incident-siren":59109,"instapay":59110,"list":59111,"loading-2":59112,"loading":59113,"location":59114,"lock":59115,"looks-one":59116,"looks-two":59117,"media-content":59118,"menu":59119,"money-notes":59120,"moneybag":59121,"moon":59122,"multiple-stars":59123,"multiple-users":59124,"node":59125,"open-folder":59126,"paperclip":59127,"payment-summary":59128,"pencil":59129,"phone":59130,"piggy-bank":59131,"plane-up":59132,"plane":59133,"play-circle":59134,"print":59135,"raising-hands":59136,"reply-arrow":59137,"reply":59138,"reschedule":59139,"rostering":59140,"save":59141,"schedule-send":59142,"schedule":59143,"search-person":59144,"send":59145,"speaker-active":59146,"speaker":59147,"star-award":59148,"star-badge":59149,"star-circle":59150,"star-medal":59151,"star":59152,"steps-circle":59153,"stopwatch":59154,"suitcase":59155,"surfing":59156,"survey":59157,"swag-pillar-benefit":59158,"swag-pillar-career":59159,"swag-pillar-money":59160,"swag-pillar-work":59161,"swag":59162,"switch":59163,"tag":59164,"target":59165,"teams":59166,"timesheet":59167,"touch-id":59168,"trash-bin":59169,"unlock":59170,"user":59171,"video-1":59172,"video-2":59173,"wallet":59174,"warning":59175,"activate-outlined":59176,"add-credit-card-outlined":59177,"add-person-outlined":59178,"add-section-outlined":59179,"add-time-outlined":59180,"add":59181,"adjustment-outlined":59182,"alignment-2-outlined":
|
|
1
|
+
{"activate":59000,"add-emoji":59001,"add-person":59002,"adjustment":59003,"alignment":59004,"antenna":59005,"archive":59006,"assignment-warning":59007,"bank":59008,"bell":59009,"billing":59010,"bolt":59011,"bookmark-added":59012,"bookmark":59013,"box-check":59014,"box":59015,"bpay":59016,"buildings":59017,"cake":59018,"calendar-clock":59019,"calendar":59020,"candy-box-menu":59021,"caret-down-small":59022,"caret-down":59023,"caret-left-small":59024,"caret-left":59025,"caret-right-small":59026,"caret-right":59027,"caret-up-small":59028,"caret-up":59029,"check-radio":59030,"circle-add":59031,"circle-cancel":59032,"circle-check":59033,"circle-down":59034,"circle-info":59035,"circle-left":59036,"circle-ok":59037,"circle-pencil":59038,"circle-question":59039,"circle-remove":59040,"circle-right":59041,"circle-up":59042,"circle-warning":59043,"clock-3":59044,"clock":59045,"cloud-download":59046,"cloud-upload":59047,"cog":59048,"coin":59049,"contacts":59050,"credit-card":59051,"diamond":59052,"direction-arrows":59053,"directory":59054,"document":59055,"dollar-coin-shine":59056,"double-buildings":59057,"edit-template":59058,"envelope":59059,"exclude":59060,"expense":59061,"eye-circle":59062,"eye-invisible":59063,"eye":59064,"face-meh":59065,"face-sad":59066,"face-smiley":59067,"feed":59068,"feedbacks":59069,"file-certified":59070,"file-clone":59071,"file-copy":59072,"file-csv":59073,"file-dispose":59074,"file-doc":59075,"file-excel":59076,"file-export":59077,"file-lock":59078,"file-pdf":59079,"file-powerpoint":59080,"file-search":59081,"file-secured":59082,"file-sheets":59083,"file-slide":59084,"file-verified":59085,"file-word":59086,"file":59087,"filter":59088,"folder-user":59089,"folder":59090,"format-bold":59091,"format-heading1":59092,"format-heading2":59093,"format-italic":59094,"format-list-bulleted":59095,"format-list-numbered":59096,"format-underlined":59097,"funnel-filter":59098,"global-dollar":59099,"globe":59100,"graduation-cap":59101,"graph":59102,"happy-sun":59103,"health-bag":59104,"heart":59105,"home":59106,"image":59107,"import":59108,"incident-siren":59109,"instapay":59110,"list":59111,"loading-2":59112,"loading":59113,"location":59114,"lock":59115,"looks-one":59116,"looks-two":59117,"media-content":59118,"menu":59119,"money-notes":59120,"moneybag":59121,"moon":59122,"multiple-stars":59123,"multiple-users":59124,"node":59125,"open-folder":59126,"paperclip":59127,"payment-summary":59128,"pencil":59129,"phone":59130,"piggy-bank":59131,"plane-up":59132,"plane":59133,"play-circle":59134,"print":59135,"raising-hands":59136,"reply-arrow":59137,"reply":59138,"reschedule":59139,"rostering":59140,"save":59141,"schedule-send":59142,"schedule":59143,"search-person":59144,"send":59145,"speaker-active":59146,"speaker":59147,"star-award":59148,"star-badge":59149,"star-circle":59150,"star-medal":59151,"star":59152,"steps-circle":59153,"stopwatch":59154,"suitcase":59155,"surfing":59156,"survey":59157,"swag-pillar-benefit":59158,"swag-pillar-career":59159,"swag-pillar-money":59160,"swag-pillar-work":59161,"swag":59162,"switch":59163,"tag":59164,"target":59165,"teams":59166,"timesheet":59167,"touch-id":59168,"trash-bin":59169,"unlock":59170,"user":59171,"video-1":59172,"video-2":59173,"wallet":59174,"warning":59175,"activate-outlined":59176,"add-credit-card-outlined":59177,"add-person-outlined":59178,"add-section-outlined":59179,"add-time-outlined":59180,"add":59181,"adjustment-outlined":59182,"ai-outlined":59183,"alignment-2-outlined":59184,"alignment-outlined":59185,"all-caps":59186,"arrow-down":59187,"arrow-downwards":59188,"arrow-left":59189,"arrow-leftwards":59190,"arrow-right":59191,"arrow-rightwards":59192,"arrow-up":59193,"arrow-upwards":59194,"article-outlined":59195,"at-sign":59196,"auto-graph-outlined":59197,"beer-outlined":59198,"bell-active-outlined":59199,"bell-outlined":59200,"bell-slash-outlined":59201,"billing-outlined":59202,"body-outlined":59203,"bold":59204,"book-outlined":59205,"bookmark-added-outlined":59206,"bookmark-outlined":59207,"box-check-outlined":59208,"box-outlined":59209,"bullet-points":59210,"cake-outlined":59211,"calendar-dates-outlined":59212,"calendar-star-outlined":59213,"call-split-outlined":59214,"camera-outlined":59215,"cancel":59216,"car-forward-outlined":59217,"charging-station-outlined":59218,"chat-bubble-outlined":59219,"chat-unread-outlined":59220,"checkmark":59221,"circle-add-outlined":59222,"circle-cancel-outlined":59223,"circle-down-outlined":59224,"circle-info-outlined":59225,"circle-left-outlined":59226,"circle-ok-outlined":59227,"circle-question-outlined":59228,"circle-remove-outlined":59229,"circle-right-outlined":59230,"circle-up-outlined":59231,"circle-warning-outlined":59232,"clock-2-outlined":59233,"clock-outlined":59234,"cog-outlined":59235,"coin-outlined":59236,"coin-super-outlined":59237,"comment-outlined":59238,"contacts-outlined":59239,"contacts-user-outlined":59240,"credit-card-outlined":59241,"cup-outlined":59242,"dentistry-outlined":59243,"direction-arrows-outlined":59244,"directory-outlined":59245,"document-outlined":59246,"dollar-box-outlined":59247,"dollar-card-outlined":59248,"dollar-coin-shine-outlined":59249,"dollar-credit-card-outlined":59250,"dollar-sign":59251,"double-buildings-outlined":59252,"double-left-arrows":59253,"double-right-arrows":59254,"download-box-outlined":59255,"download-outlined":59256,"edit-template-outlined":59257,"email-outlined":59258,"enter-arrow":59259,"envelope-outlined":59260,"expense-outlined":59261,"explore-outlined":59262,"extension-outlined":59263,"external-link":59264,"eye-invisible-outlined":59265,"eye-outlined":59266,"face-id":59267,"face-meh-outlined":59268,"face-open-smiley-outlined":59269,"face-sad-outlined":59270,"face-smiley-outlined":59271,"fastfood-outlined":59272,"feed-outlined":59273,"file-certified-outlined":59274,"file-clone-outlined":59275,"file-copy-outlined":59276,"file-dispose-outlined":59277,"file-dollar-certified-outlined":59278,"file-dollar-outlined":59279,"file-download-outlined":59280,"file-export-outlined":59281,"file-lock-outlined":59282,"file-outlined":59283,"file-search-outlined":59284,"file-secured-outlined":59285,"file-statutory-outlined":59286,"file-verified-outlined":59287,"filter-outlined":59288,"folder-outlined":59289,"folder-user-outlined":59290,"form-outlined":59291,"funnel-filter-outline":59292,"graph-outlined":59293,"hand-holding-user-outlined":59294,"happy-sun-outlined":59295,"health-bag-outlined":59296,"heart-outlined":59297,"home-active-outlined":59298,"home-outlined":59299,"id-card-outlined":59300,"image-outlined":59301,"import-outlined":59302,"instapay-outlined":59303,"italic":59304,"link-1":59305,"link-2":59306,"list-outlined":59307,"live-help-outlined":59308,"location-on-outlined":59309,"location-outlined":59310,"lock-outlined":59311,"locked-file-outlined":59312,"log-out":59313,"media-content-outlined":59314,"menu-close":59315,"menu-expand":59316,"menu-fold-outlined":59317,"menu-unfold-outlined":59318,"moneybag-outlined":59319,"moon-outlined":59320,"more-horizontal":59321,"more-vertical":59322,"multiple-folders-outlined":59323,"multiple-users-outlined":59324,"near-me-outlined":59325,"node-outlined":59326,"number-points":59327,"number":59328,"overview-outlined":59329,"payment-summary-outlined":59330,"payslip-outlined":59331,"pencil-outlined":59332,"percentage":59333,"phone-outlined":59334,"piggy-bank-outlined":59335,"plane-outlined":59336,"play-circle-outlined":59337,"print-outlined":59338,"qr-code-outlined":59339,"qualification-outlined":59340,"re-assign":59341,"redeem":59342,"refresh":59343,"remove":59344,"reply-outlined":59345,"restart":59346,"return-arrow":59347,"rostering-outlined":59348,"save-outlined":59349,"schedule-outlined":59350,"search-outlined":59351,"search-secured-outlined":59352,"send-outlined":59353,"share-1":59354,"share-2":59355,"share-outlined":59356,"show-chart-outlined":59357,"single-down-arrow":59358,"single-left-arrow":59359,"single-right-arrow":59360,"single-up-arrow":59361,"speaker-active-outlined":59362,"speaker-outlined":59363,"star-circle-outlined":59364,"star-outlined":59365,"stopwatch-outlined":59366,"strikethrough":59367,"styler-outlined":59368,"suitcase-clock-outlined":59369,"suitcase-outlined":59370,"survey-outlined":59371,"switch-outlined":59372,"sync":59373,"tag-outlined":59374,"target-outlined":59375,"tennis-outlined":59376,"ticket-outlined":59377,"timesheet-outlined":59378,"today-outlined":59379,"transfer":59380,"trash-bin-outlined":59381,"umbrela-outlined":59382,"unavailable":59383,"underline":59384,"union-outlined":59385,"unlock-outlined":59386,"upload-outlined":59387,"user-circle-outlined":59388,"user-gear-outlined":59389,"user-outlined":59390,"user-rectangle-outlined":59391,"video-1-outlined":59392,"video-2-outlined":59393,"volunteer-outlined":59394,"wallet-outlined":59395}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import styled from '@emotion/native';
|
|
2
2
|
import { TouchableOpacity, View } from 'react-native';
|
|
3
3
|
import type { ViewProps } from 'react-native';
|
|
4
|
+
import Typography from '../Typography';
|
|
4
5
|
|
|
5
6
|
const ToolbarWrapper = styled(View)<ViewProps>(({ theme }) => ({
|
|
6
7
|
position: 'absolute',
|
|
@@ -10,7 +11,6 @@ const ToolbarWrapper = styled(View)<ViewProps>(({ theme }) => ({
|
|
|
10
11
|
zIndex: 9999,
|
|
11
12
|
elevation: 9999,
|
|
12
13
|
width: '100%',
|
|
13
|
-
paddingVertical: theme.__hd__.toolbar.space.verticalPadding,
|
|
14
14
|
paddingHorizontal: theme.__hd__.toolbar.space.horizontalPadding,
|
|
15
15
|
borderTopWidth: theme.__hd__.toolbar.borderWidths.default,
|
|
16
16
|
borderColor: theme.__hd__.toolbar.colors.border,
|
|
@@ -35,9 +35,30 @@ const ToolbarGroupWrapper = styled(View)<{
|
|
|
35
35
|
}));
|
|
36
36
|
|
|
37
37
|
const ToolbarItemWrapper = styled(TouchableOpacity)(({ theme }) => ({
|
|
38
|
+
height: theme.__hd__.toolbar.sizes.itemWrapperHeight,
|
|
38
39
|
paddingVertical: theme.__hd__.toolbar.space.verticalPadding,
|
|
39
40
|
paddingHorizontal: theme.__hd__.toolbar.space.horizontalPadding,
|
|
40
41
|
alignItems: 'center',
|
|
42
|
+
flexDirection: 'row',
|
|
43
|
+
}));
|
|
44
|
+
|
|
45
|
+
const IconButtonWrapper = styled(View)(({ theme }) => ({
|
|
46
|
+
backgroundColor: theme.__hd__.toolbar.colors.iconButtonBackground,
|
|
47
|
+
borderRadius: theme.__hd__.toolbar.radii.iconButtonWrapperBorderRadius,
|
|
48
|
+
justifyContent: 'center',
|
|
49
|
+
alignItems: 'center',
|
|
50
|
+
flexDirection: 'row',
|
|
51
|
+
padding: theme.__hd__.toolbar.space.iconButtonWrapperPadding,
|
|
52
|
+
}));
|
|
53
|
+
|
|
54
|
+
const IconButtonLabel = styled(Typography.Text)(({ theme }) => ({
|
|
55
|
+
marginLeft: theme.__hd__.toolbar.space.iconButtonLabelMarginLeft,
|
|
41
56
|
}));
|
|
42
57
|
|
|
43
|
-
export {
|
|
58
|
+
export {
|
|
59
|
+
ToolbarWrapper,
|
|
60
|
+
ToolbarGroupWrapper,
|
|
61
|
+
ToolbarItemWrapper,
|
|
62
|
+
IconButtonWrapper,
|
|
63
|
+
IconButtonLabel,
|
|
64
|
+
};
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { ToolbarGroupWrapper } from './StyledToolbar';
|
|
3
3
|
import ToolbarItem from './ToolbarItem';
|
|
4
4
|
import type { ToolbarItemProps } from './ToolbarItem';
|
|
5
|
+
import { useDeprecation } from '../../utils/hooks';
|
|
5
6
|
|
|
6
7
|
export interface ToolbarGroupProps {
|
|
7
8
|
/**
|
|
@@ -15,9 +16,8 @@ export interface ToolbarGroupProps {
|
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
const ToolbarGroup = ({ align = 'right', items = [] }: ToolbarGroupProps) => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const maxWidth = items.length > 0 ? `${100 / items.length}%` : undefined;
|
|
19
|
+
useDeprecation("Toolbar's align prop is deprecated", align !== 'right');
|
|
20
|
+
|
|
21
21
|
return (
|
|
22
22
|
<ToolbarGroupWrapper align={align}>
|
|
23
23
|
{items.map(({ label, icon, onPress, disabled, intent }) => (
|
|
@@ -28,7 +28,6 @@ const ToolbarGroup = ({ align = 'right', items = [] }: ToolbarGroupProps) => {
|
|
|
28
28
|
intent={intent}
|
|
29
29
|
onPress={onPress}
|
|
30
30
|
disabled={disabled}
|
|
31
|
-
style={{ maxWidth }}
|
|
32
31
|
/>
|
|
33
32
|
))}
|
|
34
33
|
</ToolbarGroupWrapper>
|
|
@@ -2,7 +2,11 @@ import React from 'react';
|
|
|
2
2
|
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
3
|
import Icon from '../Icon';
|
|
4
4
|
import Typography from '../Typography';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
IconButtonLabel,
|
|
7
|
+
IconButtonWrapper,
|
|
8
|
+
ToolbarItemWrapper,
|
|
9
|
+
} from './StyledToolbar';
|
|
6
10
|
import type { IconName } from '../Icon';
|
|
7
11
|
|
|
8
12
|
export interface ToolbarItemProps {
|
|
@@ -33,35 +37,87 @@ export interface ToolbarItemProps {
|
|
|
33
37
|
style?: StyleProp<ViewStyle>;
|
|
34
38
|
}
|
|
35
39
|
|
|
36
|
-
|
|
37
|
-
icon
|
|
38
|
-
label
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}:
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
type IconItemProps = {
|
|
41
|
+
icon: IconName;
|
|
42
|
+
label?: string;
|
|
43
|
+
intent?: ToolbarItemProps['intent'];
|
|
44
|
+
disabled?: boolean;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const IconItem = ({ icon, intent, disabled, label }: IconItemProps) => {
|
|
48
|
+
return (
|
|
49
|
+
<IconButtonWrapper>
|
|
46
50
|
<Icon
|
|
47
51
|
icon={icon}
|
|
48
|
-
size=
|
|
52
|
+
size="medium"
|
|
49
53
|
intent={disabled ? 'disabled-text' : intent}
|
|
50
54
|
testID={`toolbar-item-icon-${icon}`}
|
|
51
55
|
/>
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
{label ? (
|
|
57
|
+
<IconButtonLabel
|
|
58
|
+
fontSize="large"
|
|
59
|
+
fontWeight="semi-bold"
|
|
60
|
+
intent={disabled ? 'subdued' : intent}
|
|
61
|
+
allowFontScaling={false}
|
|
62
|
+
numberOfLines={1}
|
|
63
|
+
>
|
|
64
|
+
{label}
|
|
65
|
+
</IconButtonLabel>
|
|
66
|
+
) : null}
|
|
67
|
+
</IconButtonWrapper>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
type ToolbarItemContentProps = {
|
|
72
|
+
icon?: IconName;
|
|
73
|
+
label?: string;
|
|
74
|
+
intent?: ToolbarItemProps['intent'];
|
|
75
|
+
disabled?: boolean;
|
|
76
|
+
};
|
|
77
|
+
const ToolbarItemContent = ({
|
|
78
|
+
icon,
|
|
79
|
+
label,
|
|
80
|
+
intent = 'primary',
|
|
81
|
+
disabled = false,
|
|
82
|
+
}: ToolbarItemContentProps): JSX.Element | null => {
|
|
83
|
+
if (icon) {
|
|
84
|
+
return (
|
|
85
|
+
<IconItem icon={icon} intent={intent} disabled={disabled} label={label} />
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
if (label) {
|
|
89
|
+
return (
|
|
54
90
|
<Typography.Text
|
|
55
|
-
fontSize=
|
|
91
|
+
fontSize="large"
|
|
56
92
|
fontWeight="semi-bold"
|
|
57
|
-
intent={disabled ? '
|
|
93
|
+
intent={disabled ? 'disabled' : intent}
|
|
58
94
|
allowFontScaling={false}
|
|
59
95
|
numberOfLines={1}
|
|
60
96
|
>
|
|
61
97
|
{label}
|
|
62
98
|
</Typography.Text>
|
|
63
|
-
)
|
|
64
|
-
|
|
65
|
-
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
return null;
|
|
102
|
+
};
|
|
103
|
+
const ToolbarItem = ({
|
|
104
|
+
icon,
|
|
105
|
+
label,
|
|
106
|
+
onPress,
|
|
107
|
+
intent = 'primary',
|
|
108
|
+
disabled = false,
|
|
109
|
+
style,
|
|
110
|
+
}: ToolbarItemProps) => {
|
|
111
|
+
return (
|
|
112
|
+
<ToolbarItemWrapper onPress={onPress} disabled={disabled} style={style}>
|
|
113
|
+
<ToolbarItemContent
|
|
114
|
+
icon={icon}
|
|
115
|
+
label={label}
|
|
116
|
+
intent={intent}
|
|
117
|
+
disabled={disabled}
|
|
118
|
+
/>
|
|
119
|
+
</ToolbarItemWrapper>
|
|
120
|
+
);
|
|
121
|
+
};
|
|
66
122
|
|
|
67
123
|
export default ToolbarItem;
|
|
@@ -5,30 +5,47 @@ import ToolbarItem from '../ToolbarItem';
|
|
|
5
5
|
|
|
6
6
|
describe('ToolbarItems', () => {
|
|
7
7
|
it.each`
|
|
8
|
-
intent
|
|
9
|
-
${'primary'}
|
|
10
|
-
${'
|
|
11
|
-
${'
|
|
12
|
-
${'
|
|
13
|
-
${'
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
8
|
+
intent | icon | label | disabled
|
|
9
|
+
${'primary'} | ${'ai-outlined'} | ${'Try again'} | ${false}
|
|
10
|
+
${'primary'} | ${'ai-outlined'} | ${undefined} | ${false}
|
|
11
|
+
${'primary'} | ${'ai-outlined'} | ${'Try again'} | ${true}
|
|
12
|
+
${'info'} | ${undefined} | ${'Save'} | ${false}
|
|
13
|
+
${'success'} | ${undefined} | ${'Save'} | ${false}
|
|
14
|
+
${'danger'} | ${undefined} | ${'Discard'} | ${false}
|
|
15
|
+
${'warning'} | ${undefined} | ${'Warning'} | ${false}
|
|
16
|
+
`(
|
|
17
|
+
'renders correctly when intent is $intent, icon is $icon, label is $label and disabled is $disabled',
|
|
18
|
+
({ intent, icon, label, disabled }) => {
|
|
19
|
+
const onPress = jest.fn();
|
|
20
|
+
const { toJSON, getByText, getByTestId } = renderWithTheme(
|
|
21
|
+
<ToolbarItem
|
|
22
|
+
label={label}
|
|
23
|
+
intent={intent}
|
|
24
|
+
icon={icon}
|
|
25
|
+
onPress={onPress}
|
|
26
|
+
disabled={disabled}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
24
29
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
expect(toJSON()).toMatchSnapshot();
|
|
31
|
+
if (icon) {
|
|
32
|
+
expect(getByTestId(`toolbar-item-icon-${icon}`)).toBeDefined();
|
|
33
|
+
}
|
|
28
34
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
35
|
+
if (label) {
|
|
36
|
+
expect(getByText(label)).toBeDefined();
|
|
37
|
+
fireEvent.press(getByText(label));
|
|
38
|
+
if (disabled) {
|
|
39
|
+
expect(onPress).not.toBeCalled();
|
|
40
|
+
} else {
|
|
41
|
+
expect(onPress).toBeCalled();
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
fireEvent.press(getByTestId(`toolbar-item-icon-${icon}`));
|
|
45
|
+
expect(onPress).toBeCalled();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
);
|
|
32
49
|
|
|
33
50
|
it('renders correctly when disabled', () => {
|
|
34
51
|
const onPress = jest.fn();
|