@cleartrip/ct-design-alert-callout 4.0.0 → 5.0.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/README.md +88 -0
- package/dist/AlertCallout.d.ts +3 -4
- package/dist/AlertCallout.d.ts.map +1 -1
- package/dist/constants.d.ts +11 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/ct-design-alert-callout.browser.cjs.js +1 -1
- package/dist/ct-design-alert-callout.browser.cjs.js.map +1 -1
- package/dist/ct-design-alert-callout.browser.esm.js +1 -1
- package/dist/ct-design-alert-callout.browser.esm.js.map +1 -1
- package/dist/ct-design-alert-callout.cjs.js +76 -30
- package/dist/ct-design-alert-callout.cjs.js.map +1 -1
- package/dist/ct-design-alert-callout.esm.js +77 -26
- package/dist/ct-design-alert-callout.esm.js.map +1 -1
- package/dist/ct-design-alert-callout.umd.js +78 -136
- package/dist/ct-design-alert-callout.umd.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/style.d.ts +36 -4
- package/dist/style.d.ts.map +1 -1
- package/dist/type.d.ts +15 -21
- package/dist/type.d.ts.map +1 -1
- package/package.json +27 -9
- package/src/AlertCallout.tsx +98 -0
- package/src/constants.ts +10 -0
- package/src/index.ts +3 -0
- package/src/style.ts +63 -0
- package/src/type.ts +78 -0
package/src/style.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { makeStyles } from '@cleartrip/ct-design-style-manager';
|
|
2
|
+
import { BaseTheme } from '@cleartrip/ct-design-theme';
|
|
3
|
+
|
|
4
|
+
import { AlertCalloutVariant } from './type';
|
|
5
|
+
import { AlertCalloutVariants } from './constants';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Static, platform-agnostic styles for AlertCallout.
|
|
9
|
+
*
|
|
10
|
+
* The variant-dependent background colour is merged in at render time via
|
|
11
|
+
* `useStyles` (see AlertCallout.tsx / AlertCallout.native.tsx). These
|
|
12
|
+
* static entries cover the structural layout only.
|
|
13
|
+
*/
|
|
14
|
+
const alertCalloutStaticStyles = makeStyles((theme) => ({
|
|
15
|
+
rootContainer: {
|
|
16
|
+
display: 'flex',
|
|
17
|
+
flexDirection: 'column',
|
|
18
|
+
justifyContent: 'center',
|
|
19
|
+
paddingVertical: theme.spacing[2],
|
|
20
|
+
paddingHorizontal: theme.spacing[3],
|
|
21
|
+
borderRadius: theme.border.radius[8],
|
|
22
|
+
},
|
|
23
|
+
// Flex helpers — replacements for aldenui's global `gs` shortcuts.
|
|
24
|
+
flexRowBetween: {
|
|
25
|
+
display: 'flex',
|
|
26
|
+
flexDirection: 'row',
|
|
27
|
+
alignItems: 'center',
|
|
28
|
+
justifyContent: 'space-between',
|
|
29
|
+
},
|
|
30
|
+
flexRow: {
|
|
31
|
+
display: 'flex',
|
|
32
|
+
flexDirection: 'row',
|
|
33
|
+
alignItems: 'center',
|
|
34
|
+
},
|
|
35
|
+
flexMiddle: {
|
|
36
|
+
display: 'flex',
|
|
37
|
+
alignItems: 'center',
|
|
38
|
+
},
|
|
39
|
+
prefixIconSpacing: {
|
|
40
|
+
flexShrink: 0,
|
|
41
|
+
marginRight: theme.spacing[2],
|
|
42
|
+
},
|
|
43
|
+
rightActionSpacing: {
|
|
44
|
+
flexShrink: 0,
|
|
45
|
+
marginLeft: theme.spacing[3],
|
|
46
|
+
},
|
|
47
|
+
}));
|
|
48
|
+
|
|
49
|
+
const COLOR_MAPPING: Partial<Record<AlertCalloutVariants, string>> = {
|
|
50
|
+
[AlertCalloutVariants.SUCCESS]: BaseTheme.color.alert.success,
|
|
51
|
+
[AlertCalloutVariants.ERROR]: BaseTheme.color.alert.error,
|
|
52
|
+
[AlertCalloutVariants.WARNING]: BaseTheme.color.alert.warning,
|
|
53
|
+
[AlertCalloutVariants.WARNING_LIGHT]: BaseTheme.color.alert.warningLight,
|
|
54
|
+
[AlertCalloutVariants.INFO]: BaseTheme.color.alert.info,
|
|
55
|
+
[AlertCalloutVariants.NEUTRAL]: BaseTheme.color.alert.neutral,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export function getAlertCalloutColourCode(variant?: AlertCalloutVariant): string {
|
|
59
|
+
const resolved = variant ?? AlertCalloutVariants.SUCCESS;
|
|
60
|
+
return COLOR_MAPPING[resolved] ?? (COLOR_MAPPING[AlertCalloutVariants.SUCCESS] || '');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export default alertCalloutStaticStyles;
|
package/src/type.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import type { Styles, TextStyle } from '@cleartrip/ct-design-types';
|
|
4
|
+
|
|
5
|
+
import { AlertCalloutVariants } from './constants';
|
|
6
|
+
|
|
7
|
+
export type AlertCalloutVariant = `${AlertCalloutVariants}`;
|
|
8
|
+
|
|
9
|
+
export interface IAlertCalloutStyleConfig {
|
|
10
|
+
/**
|
|
11
|
+
* Styles for the root container of the alert callout. Applied on top of
|
|
12
|
+
* the variant's default background + padding.
|
|
13
|
+
*/
|
|
14
|
+
root?: Styles[];
|
|
15
|
+
/**
|
|
16
|
+
* Styles for the flex wrapper that holds the prefix icon + text node.
|
|
17
|
+
*/
|
|
18
|
+
rootContainer?: Styles[];
|
|
19
|
+
/**
|
|
20
|
+
* Styles for the container wrapping the prefix icon.
|
|
21
|
+
*/
|
|
22
|
+
prefixIconContainer?: Styles[];
|
|
23
|
+
/**
|
|
24
|
+
* Styles for the immediate wrapper around the text node.
|
|
25
|
+
*/
|
|
26
|
+
textNodeContainerWrapper?: Styles[];
|
|
27
|
+
/**
|
|
28
|
+
* Styles applied to the text node (when it is rendered as a Typography —
|
|
29
|
+
* i.e. when `textNode` is a string).
|
|
30
|
+
*/
|
|
31
|
+
textNodeContainer?: TextStyle[];
|
|
32
|
+
/**
|
|
33
|
+
* Styles for the container wrapping the right action node.
|
|
34
|
+
*/
|
|
35
|
+
rightActionContainer?: Styles[];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface IAlertCalloutProps {
|
|
39
|
+
/**
|
|
40
|
+
* The variant of the alert callout.
|
|
41
|
+
*/
|
|
42
|
+
variant?: AlertCalloutVariant;
|
|
43
|
+
/**
|
|
44
|
+
* Prefix icon rendered on the leading edge of the callout.
|
|
45
|
+
*/
|
|
46
|
+
prefixIconNode?: ReactNode;
|
|
47
|
+
/**
|
|
48
|
+
* Main content of the callout. When a string is provided, it is rendered
|
|
49
|
+
* inside a Typography variant="P3"; when a ReactNode is provided, it is
|
|
50
|
+
* rendered as-is.
|
|
51
|
+
*/
|
|
52
|
+
textNode: ReactNode;
|
|
53
|
+
/**
|
|
54
|
+
* Action node rendered on the trailing edge of the callout.
|
|
55
|
+
*/
|
|
56
|
+
rightActionNode?: ReactNode;
|
|
57
|
+
/**
|
|
58
|
+
* Optional description content rendered below the main callout row.
|
|
59
|
+
*/
|
|
60
|
+
description?: ReactNode;
|
|
61
|
+
/**
|
|
62
|
+
* Callback fired when the root container is clicked.
|
|
63
|
+
*/
|
|
64
|
+
onClick?: () => void;
|
|
65
|
+
/**
|
|
66
|
+
* Style configuration overrides for each internal container.
|
|
67
|
+
*/
|
|
68
|
+
styleConfig?: IAlertCalloutStyleConfig;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @deprecated Kept for backward compatibility with the previous
|
|
73
|
+
* emotion-styled implementation; use the variant + styleConfig API instead.
|
|
74
|
+
*/
|
|
75
|
+
export interface IStyledAlertCallout {
|
|
76
|
+
variant: AlertCalloutVariant;
|
|
77
|
+
css?: Styles;
|
|
78
|
+
}
|