mattermost-mobile/app/screens/component_library/chip.cl.tsx
Daniel Espino García cdd91dbbb8
Standardize tags and chips through the app (#8856)
* Standardize tags and chips through the app

* Add missing texts

* Fix tests and snapshots

* Address feedback

* Fix snapshots

* Address UX feedback

* Apply text styles to outer text component

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-06-11 10:11:05 +02:00

55 lines
1.8 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React, {useMemo} from 'react';
import {Alert, View} from 'react-native';
import BaseChip from '@components/chips/base_chip';
import CompassIcon from '@components/compass_icon';
import {useTheme} from '@context/theme';
import {useBooleanProp, useStringProp} from './hooks';
import {buildComponent} from './utils';
const propPossibilities = {};
const onPress = () => Alert.alert('Button pressed!');
const ChipComponentLibrary = () => {
const theme = useTheme();
const [label, labelSelector] = useStringProp('label', 'Chip text', false);
const [showRemoveOption, showRemoveOptionSelector] = useBooleanProp('showRemoveOption', false);
const [hasPrefix, hasPrefixSelector] = useBooleanProp('hasPrefix', false);
const components = useMemo(
() => buildComponent(BaseChip, propPossibilities, [], [
label,
showRemoveOption,
{
onPress,
prefix: hasPrefix.hasPrefix ? (
<CompassIcon
name='account-outline'
size={16}
color={theme.centerChannelColor}
style={{marginLeft: 6}}
/>
) : undefined,
testID: 'chip-example',
theme,
},
]),
[label, showRemoveOption, hasPrefix.hasPrefix, theme],
);
return (
<>
{labelSelector}
{showRemoveOptionSelector}
{hasPrefixSelector}
<View style={{flexDirection: 'row', flexWrap: 'wrap', gap: 8, marginTop: 16}}>{components}</View>
</>
);
};
export default ChipComponentLibrary;