Skip to content

Commit

Permalink
feat(foundation): added reaction ui color
Browse files Browse the repository at this point in the history
  • Loading branch information
bang9 committed Dec 6, 2022
1 parent 805fce5 commit 5b272e5
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ const preProcessor: Partial<StylePreprocessor> = {
'lineHeight': DEFAULT_SCALE_FACTOR,
'borderRadius': DEFAULT_SCALE_FACTOR,
'minWidth': SCALE_FACTOR_WITH_STR,
'maxWidth': SCALE_FACTOR_WITH_STR,
'minHeight': SCALE_FACTOR_WITH_STR,
'maxHeight': SCALE_FACTOR_WITH_STR,
'height': SCALE_FACTOR_WITH_STR,
'width': SCALE_FACTOR_WITH_STR,
'padding': SCALE_FACTOR_WITH_STR,
Expand Down
22 changes: 22 additions & 0 deletions packages/uikit-react-native-foundation/src/theme/DarkUIKitTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,28 @@ const DarkUIKitTheme = createTheme({
},
},
},
reaction: {
default: {
enabled: {
background: palette.transparent,
highlight: palette.onBackgroundDark03,
},
selected: {
background: palette.primary500,
highlight: palette.primary200,
},
},
rounded: {
enabled: {
background: palette.background400,
highlight: palette.transparent,
},
selected: {
background: palette.primary500,
highlight: palette.transparent,
},
},
},
},
}),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,28 @@ const LightUIKitTheme = createTheme({
},
},
},
reaction: {
default: {
enabled: {
background: palette.transparent,
highlight: palette.onBackgroundLight03,
},
selected: {
background: palette.primary100,
highlight: palette.primary300,
},
},
rounded: {
enabled: {
background: palette.background100,
highlight: palette.transparent,
},
selected: {
background: palette.primary100,
highlight: palette.transparent,
},
},
},
},
}),
});
Expand Down
7 changes: 6 additions & 1 deletion packages/uikit-react-native-foundation/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export type Component =
| 'Message'
| 'DateSeparator'
| 'GroupChannelPreview'
| 'ProfileCard';
| 'ProfileCard'
| 'Reaction';

export type GetColorTree<
Tree extends {
Expand Down Expand Up @@ -68,6 +69,7 @@ export type ComponentColorTree = GetColorTree<{
DateSeparator: 'default';
GroupChannelPreview: 'default';
ProfileCard: 'default';
Reaction: 'default' | 'rounded';
};
State: {
Header: 'none';
Expand All @@ -80,6 +82,7 @@ export type ComponentColorTree = GetColorTree<{
DateSeparator: 'none';
GroupChannelPreview: 'none';
ProfileCard: 'none';
Reaction: 'enabled' | 'selected';
};
ColorPart: {
Header: 'background' | 'borderBottom';
Expand All @@ -101,6 +104,7 @@ export type ComponentColorTree = GetColorTree<{
| 'bodyIconBackground'
| 'separator';
ProfileCard: 'textUsername' | 'textBodyLabel' | 'textBody' | 'background';
Reaction: 'background' | 'highlight';
};
}>;
export type ComponentColors<T extends Component> = {
Expand Down Expand Up @@ -145,6 +149,7 @@ export interface UIKitColors {
dateSeparator: ComponentColors<'DateSeparator'>;
groupChannelPreview: ComponentColors<'GroupChannelPreview'>;
profileCard: ComponentColors<'ProfileCard'>;
reaction: ComponentColors<'Reaction'>;
};
}

Expand Down
4 changes: 2 additions & 2 deletions packages/uikit-react-native-foundation/src/ui/Badge/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { Platform, StyleProp, View, ViewStyle } from 'react-native';

import { truncatedBadgeCount } from '@sendbird/uikit-utils';
import { truncatedCount } from '@sendbird/uikit-utils';

import Text from '../../components/Text';
import createStyleSheet from '../../styles/createStyleSheet';
Expand Down Expand Up @@ -29,7 +29,7 @@ const Badge = ({ count, maxCount, badgeColor, textColor, style, size = 'default'
]}
>
<Text caption1 color={textColor ?? colors.ui.badge.default.none.text}>
{truncatedBadgeCount(count, maxCount)}
{truncatedCount(count, maxCount)}
</Text>
</View>
);
Expand Down
7 changes: 4 additions & 3 deletions packages/uikit-utils/src/ui-format/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,16 @@ export const truncate = (str: string, opts: Partial<TruncateOption> = defaultOpt
};

/**
* Badge count truncate util
* Count truncate util
* If count exceed the limit, it comes in the form of "MAX+"
*
* @param {number} count
* @param {number} MAX default 99
* @param {string} MAX_SUFFIX default +
* @returns {string}
* */
export const truncatedBadgeCount = (count: number, MAX = 99) => {
if (count >= MAX) return `${MAX}+`;
export const truncatedCount = (count: number, MAX = 99, MAX_SUFFIX = '+') => {
if (count >= MAX) return `${MAX}${MAX_SUFFIX}`;
return `${count}`;
};

Expand Down

0 comments on commit 5b272e5

Please sign in to comment.