Skip to content

Commit d659de9

Browse files
committed
fix: answers list design
1 parent 594616e commit d659de9

File tree

2 files changed

+43
-30
lines changed

2 files changed

+43
-30
lines changed

package/src/components/Poll/components/PollAnswersList.tsx

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { PollInputDialog } from './PollInputDialog';
99
import {
1010
PollContextProvider,
1111
PollContextValue,
12+
useChatContext,
1213
usePollContext,
1314
useTheme,
1415
useTranslationContext,
@@ -27,6 +28,8 @@ export const AnswerListAddCommentButton = (props: PollButtonProps) => {
2728
const [showAddCommentDialog, setShowAddCommentDialog] = useState(false);
2829
const { onPress } = props;
2930

31+
const styles = useStyles();
32+
3033
const onPressHandler = useCallback(() => {
3134
if (onPress) {
3235
onPress({ message, poll });
@@ -37,10 +40,10 @@ export const AnswerListAddCommentButton = (props: PollButtonProps) => {
3740
}, [message, onPress, poll]);
3841

3942
return (
40-
<>
43+
<View style={styles.inlineButton}>
4144
<Button
4245
variant={'secondary'}
43-
type={'outline'}
46+
type={'ghost'}
4447
size={'lg'}
4548
label={ownAnswer ? t('Update your comment') : t('Add a comment')}
4649
onPress={onPressHandler}
@@ -54,7 +57,7 @@ export const AnswerListAddCommentButton = (props: PollButtonProps) => {
5457
visible={showAddCommentDialog}
5558
/>
5659
) : null}
57-
</>
60+
</View>
5861
);
5962
};
6063

@@ -64,9 +67,12 @@ export type PollAnswersListProps = PollContextValue & {
6467
};
6568

6669
export const PollAnswerListItem = ({ answer }: { answer: PollAnswer }) => {
70+
const { client } = useChatContext();
6771
const { t, tDateTimeParser } = useTranslationContext();
6872
const { votingVisibility } = usePollState();
6973

74+
const isMyAnswer = client.userID === answer.user?.id;
75+
7076
const {
7177
theme: {
7278
poll: {
@@ -93,19 +99,22 @@ export const PollAnswerListItem = ({ answer }: { answer: PollAnswer }) => {
9399
);
94100

95101
return (
96-
<View style={[styles.listItemContainer, itemStyle.container]}>
97-
<Text style={[styles.listItemAnswerText, itemStyle.answerText]}>{answer.answer_text}</Text>
98-
<View style={[styles.listItemInfoContainer, itemStyle.infoContainer]}>
99-
<View style={[styles.listItemUserInfoContainer, itemStyle.userInfoContainer]}>
100-
{!isAnonymous && answer.user?.image ? (
101-
<UserAvatar user={answer.user} size='md' showBorder />
102-
) : null}
103-
<Text style={styles.listItemInfoUserName}>
104-
{isAnonymous ? t('Anonymous') : answer.user?.name}
105-
</Text>
102+
<View style={[styles.listItemWrapper, itemStyle.wrapper]}>
103+
<View style={[styles.listItemContainer, itemStyle.container]}>
104+
<Text style={[styles.listItemAnswerText, itemStyle.answerText]}>{answer.answer_text}</Text>
105+
<View style={[styles.listItemInfoContainer, itemStyle.infoContainer]}>
106+
<View style={[styles.listItemUserInfoContainer, itemStyle.userInfoContainer]}>
107+
{!isAnonymous && answer.user?.image ? (
108+
<UserAvatar user={answer.user} size='sm' showBorder />
109+
) : null}
110+
<Text style={styles.listItemInfoUserName}>
111+
{isAnonymous ? t('Anonymous') : answer.user?.name}
112+
</Text>
113+
<Text style={styles.listItemInfoDate}>{dateString}</Text>
114+
</View>
106115
</View>
107-
<Text style={styles.listItemInfoDate}>{dateString}</Text>
108116
</View>
117+
{isMyAnswer ? <AnswerListAddCommentButton /> : null}
109118
</View>
110119
);
111120
};
@@ -137,7 +146,6 @@ export const PollAnswersListContent = ({
137146
renderItem={renderPollAnswerListItem}
138147
{...additionalFlatListProps}
139148
/>
140-
<AnswerListAddCommentButton />
141149
</View>
142150
);
143151
};
@@ -164,46 +172,49 @@ const useStyles = () => {
164172
return useMemo(
165173
() =>
166174
StyleSheet.create({
167-
addCommentButtonContainer: {
168-
alignItems: 'center',
169-
borderRadius: 12,
170-
paddingHorizontal: 16,
171-
paddingVertical: 18,
172-
},
173175
contentContainer: { gap: primitives.spacingMd },
174-
addCommentButtonText: { fontSize: 16 },
175176
container: {
176177
flex: 1,
177178
padding: primitives.spacingMd,
178179
backgroundColor: semantics.backgroundCoreElevation1,
179180
},
180181
listItemAnswerText: {
181182
fontSize: primitives.typographyFontSizeMd,
182-
lineHeight: primitives.typographyLineHeightRelaxed,
183-
fontWeight: primitives.typographyFontWeightSemiBold,
183+
lineHeight: primitives.typographyLineHeightNormal,
184184
color: semantics.textPrimary,
185185
},
186-
listItemContainer: {
186+
listItemWrapper: {
187187
borderRadius: primitives.radiusLg,
188-
padding: primitives.spacingMd,
189188
backgroundColor: semantics.backgroundCoreSurfaceCard,
190189
},
190+
listItemContainer: {
191+
padding: primitives.spacingMd,
192+
gap: primitives.spacingXs,
193+
},
191194
listItemInfoContainer: {
192195
flexDirection: 'row',
193196
justifyContent: 'space-between',
194197
alignItems: 'center',
195-
marginTop: 24,
196198
},
197199
listItemInfoUserName: {
198-
color: semantics.textPrimary,
200+
color: semantics.chatTextUsername,
199201
fontSize: primitives.typographyFontSizeSm,
200-
marginLeft: primitives.spacingXxs,
202+
fontWeight: primitives.typographyFontWeightSemiBold,
203+
lineHeight: primitives.typographyLineHeightNormal,
201204
},
202205
listItemInfoDate: {
203206
fontSize: primitives.typographyFontSizeSm,
204207
color: semantics.textTertiary,
205208
},
206-
listItemUserInfoContainer: { alignItems: 'center', flexDirection: 'row' },
209+
listItemUserInfoContainer: {
210+
gap: primitives.spacingXs,
211+
alignItems: 'center',
212+
flexDirection: 'row',
213+
},
214+
inlineButton: {
215+
borderColor: semantics.borderCoreDefault,
216+
borderTopWidth: 1,
217+
},
207218
}),
208219
[semantics],
209220
);

package/src/contexts/themeContext/utils/theme.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,7 @@ export type Theme = {
822822
container: ViewStyle;
823823
infoContainer: ViewStyle;
824824
userInfoContainer: ViewStyle;
825+
wrapper: ViewStyle;
825826
};
826827
};
827828
button: { container: ViewStyle; text: TextStyle };
@@ -1731,6 +1732,7 @@ export const defaultTheme: Theme = {
17311732
container: {},
17321733
infoContainer: {},
17331734
userInfoContainer: {},
1735+
wrapper: {},
17341736
},
17351737
},
17361738
button: { container: {}, text: {} },

0 commit comments

Comments
 (0)