Skip to content

Commit 608259d

Browse files
authored
add filters interaction styles, improve icons, focus and spacing (#1875)
1 parent 5346174 commit 608259d

8 files changed

Lines changed: 49 additions & 26 deletions

File tree

components/Filters/ToggleLink.tsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import Link from 'next/link';
2+
import { useContext, useState } from 'react';
23
import { Platform, StyleSheet, View } from 'react-native';
34

45
import { P, colors } from '~/common/styleguide';
6+
import CustomAppearanceContext from '~/context/CustomAppearanceContext';
57
import { type Query } from '~/types';
68
import urlWithQuery from '~/util/urlWithQuery';
79

@@ -15,6 +17,8 @@ type Props = {
1517
};
1618

1719
export function ToggleLink({ query, paramName, title, basePath = '/' }: Props) {
20+
const { isDark } = useContext(CustomAppearanceContext);
21+
const [isHovered, setHovered] = useState<boolean>(false);
1822
const isSelected = !!query[paramName];
1923

2024
return (
@@ -25,9 +29,18 @@ export function ToggleLink({ query, paramName, title, basePath = '/' }: Props) {
2529
offset: null,
2630
})}
2731
style={{ textDecoration: 'none' }}>
28-
<View style={styles.link}>
29-
<CheckBox value={isSelected} color={colors.primaryDark} />
30-
<P style={styles.text}>{title}</P>
32+
<View
33+
style={styles.link}
34+
onPointerEnter={() => setHovered(true)}
35+
onPointerLeave={() => setHovered(false)}>
36+
<CheckBox
37+
value={isSelected}
38+
color={colors.primaryDark}
39+
style={isHovered && { borderColor: colors.primaryDark }}
40+
/>
41+
<P style={[styles.text, isHovered && { color: isDark ? colors.gray3 : colors.gray5 }]}>
42+
{title}
43+
</P>
3144
</View>
3245
</Link>
3346
);

components/Filters/index.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useContext } from 'react';
22
import { StyleSheet, View, ViewStyle } from 'react-native';
33

4-
import { colors, Headline, layout, darkColors } from '~/common/styleguide';
4+
import { colors, Headline, layout, darkColors, useLayout } from '~/common/styleguide';
55
import CustomAppearanceContext from '~/context/CustomAppearanceContext';
66
import { Query } from '~/types';
77
import { getPageQuery } from '~/util/search';
@@ -20,11 +20,13 @@ type FiltersProps = {
2020
basePath?: string;
2121
};
2222

23-
export const Filters = ({ query, style, basePath = '/' }: FiltersProps) => {
23+
export function Filters({ query, style, basePath = '/' }: FiltersProps) {
2424
const { isDark } = useContext(CustomAppearanceContext);
25-
const isMainSearch = basePath === '/';
25+
const { isSmallScreen } = useLayout();
2626
const pageQuery = getPageQuery(basePath, query);
2727

28+
const isMainSearch = basePath === '/';
29+
2830
const titleColor = {
2931
color: isDark ? darkColors.secondary : colors.gray5,
3032
};
@@ -77,7 +79,7 @@ export const Filters = ({ query, style, basePath = '/' }: FiltersProps) => {
7779
</View>
7880
</View>
7981
<View style={styles.twoColumns}>
80-
<View style={styles.wrappableContainer}>
82+
<View style={[styles.wrappableContainer, isSmallScreen && { maxWidth: '100%' }]}>
8183
<Headline style={[styles.title, titleColor]}>Compatibility</Headline>
8284
<View style={styles.optionsContainer}>
8385
{FILTER_COMPATIBILITY.map(platform => (
@@ -91,7 +93,7 @@ export const Filters = ({ query, style, basePath = '/' }: FiltersProps) => {
9193
))}
9294
</View>
9395
</View>
94-
<View style={styles.wrappableContainer}>
96+
<View style={[styles.wrappableContainer, isSmallScreen && { maxWidth: '100%' }]}>
9597
<Headline style={[styles.title, titleColor]}>Type</Headline>
9698
<View style={styles.optionsContainer}>
9799
<ToggleLink
@@ -120,7 +122,7 @@ export const Filters = ({ query, style, basePath = '/' }: FiltersProps) => {
120122
</View>
121123
</View>
122124
);
123-
};
125+
}
124126

125127
const styles = StyleSheet.create({
126128
wrapper: {

components/Icons/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export function Issue({ width, height, fill = colors.black }: IconProps) {
149149
<Path
150150
fillRule="evenodd"
151151
clipRule="evenodd"
152-
d="M8.49 10.999V5.005h2v5.994h-2zM9.49 14.061a1.041 1.041 0 100-2.082 1.041 1.041 0 000 2.082z"
152+
d="M9.5 7.75C9.96413 7.75 10.4092 7.93437 10.7374 8.26256C11.0656 8.59075 11.25 9.03587 11.25 9.5C11.25 9.96413 11.0656 10.4092 10.7374 10.7374C10.4092 11.0656 9.96413 11.25 9.5 11.25C9.03587 11.25 8.59075 11.0656 8.26256 10.7374C7.93437 10.4092 7.75 9.96413 7.75 9.5C7.75 9.03587 7.93437 8.59075 8.26256 8.26256C8.59075 7.93437 9.03587 7.75 9.5 7.75Z"
153153
fill={fill}
154154
/>
155155
<Path
@@ -162,12 +162,12 @@ export function Issue({ width, height, fill = colors.black }: IconProps) {
162162
);
163163
}
164164

165-
export function Eye({ width, height, fill = colors.black }: IconProps) {
165+
export function Eye({ width = 22, height = 22, fill = colors.black }: IconProps) {
166166
return (
167-
<Svg width={width ?? 22} height={height ?? 22} viewBox="0 0 24 24" fill="none">
167+
<Svg width={width} height={height} viewBox="0 0 22 22" fill="none">
168168
<Path
169169
fill={fill}
170-
d="M11.9,7.1c4.6,0,7.8,2.9,9.2,4.5c-1.4,1.8-4.6,5.2-9.2,5.2c-4.3,0-7.7-3.4-9.2-5.3C4.1,10,7.3,7.1,11.9,7.1z M12,5 C4.4,5,0,11.6,0,11.6S4.8,19,12,19c7.7,0,12-7.4,12-7.4S19.7,5,12,5z M11.9,8.5c-1.9,0-3.5,1.6-3.5,3.5s1.6,3.5,3.5,3.5 c1.9,0,3.5-1.6,3.5-3.5S13.8,8.5,11.9,8.5z M11.9,12c-0.5,0.5-1.3,0.5-1.8,0c-0.5-0.5-0.5-1.3,0-1.8c0.5-0.5,1.3-0.5,1.8,0 C12.4,10.7,12.4,11.5,11.9,12z"
170+
d="M10.9083 6.50831C15.125 6.50831 18.0583 9.16665 19.3417 10.6333C18.0583 12.2833 15.125 15.4 10.9083 15.4C6.96667 15.4 3.85 12.2833 2.475 10.5416C3.75833 9.16665 6.69167 6.50831 10.9083 6.50831ZM11 4.58331C4.03333 4.58331 0 10.6333 0 10.6333C0 10.6333 4.4 17.4166 11 17.4166C18.0583 17.4166 22 10.6333 22 10.6333C22 10.6333 18.0583 4.58331 11 4.58331ZM10.9083 7.79165C9.16667 7.79165 7.7 9.25831 7.7 11C7.7 12.7416 9.16667 14.2083 10.9083 14.2083C12.65 14.2083 14.1167 12.7416 14.1167 11C14.1167 9.25831 12.65 7.79165 10.9083 7.79165ZM10.9083 11C10.45 11.4583 9.71667 11.4583 9.25833 11C8.8 10.5416 8.8 9.80831 9.25833 9.34998C9.71667 8.89165 10.45 8.89165 10.9083 9.34998C11.3667 9.80831 11.3667 10.5416 10.9083 11Z"
171171
/>
172172
</Svg>
173173
);

components/Library/MetaData.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ const styles = StyleSheet.create({
206206
alignItems: 'center',
207207
},
208208
iconContainer: {
209-
marginRight: 8,
210-
width: 20,
209+
marginRight: 7,
210+
width: 22,
211211
alignItems: 'center',
212212
},
213213
linkContainer: {
@@ -221,6 +221,7 @@ const styles = StyleSheet.create({
221221
link: {
222222
fontSize: 15,
223223
fontWeight: 300,
224+
outlineOffset: -1,
224225
},
225226
mutedLink: {
226227
backgroundColor: 'transparent',
@@ -231,10 +232,10 @@ const styles = StyleSheet.create({
231232
},
232233
secondaryContainer: {
233234
marginBottom: 0,
234-
marginRight: 16,
235+
paddingRight: 3,
235236
},
236237
secondaryIconContainer: {
237-
marginRight: 6,
238+
marginRight: 4,
238239
},
239240
exampleLink: {
240241
marginLeft: 2,
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type Props = {
1313

1414
const GITHUB_PREVIEW_MIN_WIDTH = 640;
1515

16-
const Thumbnail = ({ url }: Props) => {
16+
function Thumbnail({ url }: Props) {
1717
const { isDark } = useContext(CustomAppearanceContext);
1818
const { width, height } = useWindowDimensions();
1919

@@ -37,6 +37,7 @@ const Thumbnail = ({ url }: Props) => {
3737
<HoverCard.Root openDelay={0} closeDelay={0} onOpenChange={open => setShowPreview(open)}>
3838
<HoverCard.Trigger asChild>
3939
<div
40+
tabIndex={0}
4041
style={{
4142
marginRight: 10,
4243
marginTop: 4,
@@ -49,8 +50,8 @@ const Thumbnail = ({ url }: Props) => {
4950
textAlign: 'center',
5051
borderWidth: 1,
5152
borderRadius: 3,
52-
borderColor: isDark ? darkColors.border : colors.gray2,
5353
borderStyle: 'solid',
54+
borderColor: isDark ? darkColors.border : colors.gray2,
5455
cursor: isLoaded ? 'pointer' : 'progress',
5556
}}>
5657
{showPreview && !isLoaded ? (
@@ -66,13 +67,13 @@ const Thumbnail = ({ url }: Props) => {
6667
<HoverCard.Content sideOffset={6} sticky="always">
6768
<div
6869
style={{
69-
backgroundColor: isDark ? darkColors.black : colors.white,
7070
opacity: 1,
7171
padding: 10,
72+
borderRadius: 4,
7273
boxSizing: 'border-box',
74+
backgroundColor: isDark ? darkColors.black : colors.white,
7375
maxWidth: maxPreviewWidth,
7476
maxHeight: maxPreviewHeight,
75-
borderRadius: 4,
7677
display: showPreview && isLoaded ? 'block' : 'none',
7778
boxShadow: `0 4px 6px 0 ${isDark ? '#2a2e3633' : '#00000025'}`,
7879
}}>
@@ -81,16 +82,16 @@ const Thumbnail = ({ url }: Props) => {
8182
onLoad={() => setLoaded(true)}
8283
alt=""
8384
style={{
85+
borderRadius: 2,
8486
maxWidth: maxPreviewImageWidth,
8587
maxHeight: maxImgPreviewHeight,
86-
borderRadius: 2,
8788
}}
8889
/>
8990
</div>
9091
</HoverCard.Content>
9192
</HoverCard.Portal>
9293
</HoverCard.Root>
9394
);
94-
};
95+
}
9596

9697
export default memo(Thumbnail);

components/Library/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import CustomAppearanceContext from '~/context/CustomAppearanceContext';
99
import { type LibraryType } from '~/types';
1010

1111
import { MetaData } from './MetaData';
12-
import Thumbnail from './Thumbnail';
12+
import Thumbnail from './Thumbnail.web';
1313
import TrendingMark from './TrendingMark';
1414
import UnmaintainedLabel from './UnmaintainedLabel';
1515
import { CompatibilityTags } from '../CompatibilityTags';
@@ -172,7 +172,6 @@ const styles = StyleSheet.create({
172172
},
173173
}),
174174
padding: 16,
175-
paddingLeft: 18,
176175
borderLeftWidth: 1,
177176
},
178177
columnTwoSmall: {
@@ -222,6 +221,7 @@ const styles = StyleSheet.create({
222221
secondaryStats: {
223222
marginTop: 12,
224223
flexWrap: 'wrap',
224+
gap: 10,
225225
},
226226
secondaryText: {
227227
fontSize: 13,

components/Search.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,12 @@ const Search = ({ query, total }: Props) => {
160160
) : (
161161
<P />
162162
)}
163-
<View style={[styles.displayHorizontal, styles.buttonsContainer]}>
163+
<View
164+
style={[
165+
styles.displayHorizontal,
166+
styles.buttonsContainer,
167+
isSmallScreen && { marginTop: 10 },
168+
]}>
164169
<FilterButton
165170
containerStyle={{ height: 24 }}
166171
style={{ height: 24 }}

pages/_app.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const App = ({ pageProps, Component }) => (
4343
outline-color: ${colors.primaryDark};
4444
outline-style: solid;
4545
outline-width: 2px;
46+
border-radius: 3px;
4647
}`}
4748
</style>
4849
</Head>

0 commit comments

Comments
 (0)