Skip to content

Commit

Permalink
ButtonCounter//ExploreListItem//Idea: use button counter everywhere a…
Browse files Browse the repository at this point in the history
…nd update styles fixes #453 fixes #454
  • Loading branch information
philli-m authored and khamui committed Apr 11, 2023
1 parent 8d81b1a commit 5987e61
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 47 deletions.
27 changes: 20 additions & 7 deletions src/components/ButtonCounter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,45 @@ import { styles } from './ButtonCounter.styles'
import { TextSourceSans } from './TextSourceSans'

export const ButtonCounter = (props) => {
const listStyle = [styles.baseText, styles.disableText, styles.listText]
let btnStyle
let textStyle
if (props.disabled) {
textStyle = [styles.text, styles.disableStyle]
btnStyle = styles.btn
textStyle = [styles.baseText, styles.disableText]
} else {
if (props.counter === 0) {
btnStyle = styles.btn
textStyle = styles.text
textStyle = styles.baseText
} else {
if (props.rating === 'pos') {
btnStyle = styles.btn
textStyle = [styles.text, styles.ratedUp]
textStyle = [styles.baseText, styles.ratedUp]
if (props.highlight) {
btnStyle = [styles.btn, styles.highlightUp]
textStyle = [styles.text, styles.ratedUp]
textStyle = [styles.baseText, styles.ratedUp]
}
} else if (props.rating === 'neg') {
btnStyle = styles.btn
textStyle = [styles.text, styles.ratedDown]
textStyle = [styles.baseText, styles.ratedDown]
if (props.highlight) {
btnStyle = [styles.btn, styles.highlightDown]
textStyle = [styles.text, styles.ratedDown]
textStyle = [styles.baseText, styles.ratedDown]
}
}
}
}

return (
return (props.list ?
<View style={styles.container}>
<TextSourceSans style={listStyle}>
{props.counter}
</TextSourceSans>
<TextSourceSans style={listStyle}>
{props.icon}
</TextSourceSans>
</View>
:
<View style={styles.container}>
<Pressable
style={btnStyle}
Expand All @@ -43,6 +54,8 @@ export const ButtonCounter = (props) => {
>
<TextSourceSans style={textStyle}>
{props.counter}
</TextSourceSans>
<TextSourceSans style={textStyle}>
{props.icon}
</TextSourceSans>
</Pressable>
Expand Down
22 changes: 12 additions & 10 deletions src/components/ButtonCounter.styles.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { StyleSheet } from 'react-native'

import { COLORS } from '../theme/colors'
import { FONTS, LETTERSPACING, LINEHEIGHTS, SIZES } from '../theme/fonts'
import { FONTS, LINEHEIGHTS, SIZES } from '../theme/fonts'
import { BORDERRADIUS, SPACINGS } from '../theme/spacings'

export const styles = StyleSheet.create({
Expand All @@ -10,24 +10,26 @@ export const styles = StyleSheet.create({
flexDirection: 'row',
},
btn: {
paddingLeft: SPACINGS.multiplyBy(.5),
paddingRight: SPACINGS.multiplyBy(.5),
paddingTop: SPACINGS.multiplyBy(.25),
paddingBottom: SPACINGS.multiplyBy(.25),
marginBottom: SPACINGS.multiplyBy(.5),
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
paddingHorizontal: SPACINGS.multiplyBy(.5),
paddingVertical: SPACINGS.multiplyBy(.4),
borderRadius: BORDERRADIUS.base,
},
text: {
letterSpacing: LETTERSPACING.iconbtn,
baseText: {
marginRight: 5,
fontSize: SIZES.md,
lineHeight: LINEHEIGHTS.sm,
fontFamily: FONTS.familySemiBold
},
disableStyle: {
fontSize: SIZES.sm,
disableText: {
color: COLORS.grey.medium,
fontFamily: FONTS.familySans
},
listText: {
fontSize: SIZES.sm,
},
ratedUp: {
color: COLORS.primary,
},
Expand Down
1 change: 1 addition & 0 deletions src/containers/Comments/Comment.styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const styles = StyleSheet.create({
},
bottomActionsContainer: {
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent: 'space-between',
alignItems: 'center',
paddingBottom: SPACINGS.multiplyBy(0.5)
Expand Down
1 change: 1 addition & 0 deletions src/containers/Ideas/ExploreListItem.styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const styles = StyleSheet.create({
padding: SPACINGS.multiplyBy(0.8),
},
progressText: {
fontSize: SIZES.sm,
color: COLORS.grey.medium
},
progressBar: {
Expand Down
22 changes: 10 additions & 12 deletions src/containers/Ideas/Idea.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,15 +300,7 @@ export const Idea = (props) => {
const optionsIcon = <IconSLI name='options-vertical' size={22} />
const arrowUpIcon = <IconSLI name='arrow-up' size={18} />
const arrowDownIcon = <IconSLI name='arrow-down' size={18} />
const commentIcon = (
<IconSLI name='bubble' size={18}
color={!hasComments
? styles.disabledIcon.color
: styles.fontColor.color
}
style={styles.commentIcon}
/>
)
const commentIcon = <IconSLI name='bubble' size={18} />

const fetchComments = (ideaContentType, ideaPk) => {
API.getComments(ideaContentType, ideaPk)
Expand Down Expand Up @@ -412,6 +404,7 @@ export const Idea = (props) => {
<ScrollView
style={styles.container}
scrollEnabled={!isEditing}
scrollEventThrottle={16}
keyboardShouldPersistTaps='handled'
onScroll={handleScroll}
ref={scrollViewRef}
Expand Down Expand Up @@ -490,9 +483,14 @@ export const Idea = (props) => {
disabled={!ideaState.has_rating_permission}
/>
</View>
<View>
{commentIcon}
</View>
{hasComments &&
<View>
<ButtonCounter
icon={commentIcon}
labelText={t('idea has comments')}
disabled
/>
</View>}
</View>
</View>
{comments && (
Expand Down
6 changes: 1 addition & 5 deletions src/containers/Ideas/Idea.styles.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { StyleSheet } from 'react-native'

import { COLORS } from '../../theme/colors'
import { FONTS, LINEHEIGHTS,SIZES } from '../../theme/fonts'
import { FONTS, LINEHEIGHTS, SIZES } from '../../theme/fonts'
import { SPACINGS } from '../../theme/spacings'

export const styles = StyleSheet.create({
Expand Down Expand Up @@ -58,10 +58,6 @@ export const styles = StyleSheet.create({
marginVertical: SPACINGS.multiplyBy(.5),
flexWrap: 'wrap',
},
commentIcon: {
fontSize: SIZES.md,
marginVertical: SPACINGS.multiplyBy(.5),
},
pressableEditing: {
opacity: 0.25,
backgroundColor: '#fff'
Expand Down
14 changes: 7 additions & 7 deletions src/containers/Ideas/IdeasListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export const IdeasListItem = (props) => {
return categoryList
}

const arrowUpIcon = <IconSLI name='arrow-up' size={18} />
const arrowDownIcon = <IconSLI name='arrow-down' size={18} />
const commentIcon = <IconSLI name='bubble' size={18} />
const arrowUpIcon = <IconSLI name='arrow-up' size={16} />
const arrowDownIcon = <IconSLI name='arrow-down' size={16} />
const commentIcon = <IconSLI name='bubble' size={16} />

return (
<TouchableOpacity
Expand All @@ -60,15 +60,15 @@ export const IdeasListItem = (props) => {
<View style={styles.noLabelSpacing}></View>)}
</View>
<View style={styles.bottomContainer}>
<TextSourceSans style={styles.text}>{creator}</TextSourceSans>
<TextSourceSans style={styles.creatorText}>{creator}</TextSourceSans>
<View style={styles.infoContainer}>
<TextSourceSans style={styles.date}>
{created}
</TextSourceSans>
<View style={styles.counters}>
<ButtonCounter icon={arrowUpIcon} counter={upCount} disabled />
<ButtonCounter icon={arrowDownIcon} counter={downCount} disabled />
<ButtonCounter icon={commentIcon} counter={commentCount} disabled />
<ButtonCounter icon={arrowUpIcon} counter={upCount} disabled list />
<ButtonCounter icon={arrowDownIcon} counter={downCount} disabled list />
<ButtonCounter icon={commentIcon} counter={commentCount} disabled list />
</View>
</View>
</View>
Expand Down
4 changes: 2 additions & 2 deletions src/containers/Ideas/IdeasListItem.styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ export const styles = StyleSheet.create({
fontSize: SIZES.base,
fontFamily: FONTS.familySemiBold
},
text: {
creatorText: {
fontSize: SIZES.sm,
marginRight: SPACINGS.multiplyBy(0.5),
flexBasis: '100%'
},
date: {
fontSize: SIZES.sm,
Expand Down
4 changes: 0 additions & 4 deletions src/theme/fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,3 @@ export const LINEHEIGHTS = {
lg: pixelRatio * 28,
xl: pixelRatio * 30,
}

export const LETTERSPACING = {
iconbtn: 5,
}

0 comments on commit 5987e61

Please sign in to comment.