Skip to content

Commit a3b97b6

Browse files
authored
correct internal link behaviour, tweak trending mark (#1831)
1 parent eba2292 commit a3b97b6

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

common/styleguide.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,22 +124,22 @@ type AProps = PropsWithChildren<{
124124
hoverStyle?: TextStyles;
125125
}>;
126126

127-
export const A = ({ href, target = '_blank', children, style, hoverStyle, ...rest }: AProps) => {
127+
export const A = ({ href, target, children, style, hoverStyle, ...rest }: AProps) => {
128128
const { isDark } = useContext(CustomAppearanceContext);
129129
const [isHovered, setIsHovered] = useState(false);
130130

131131
const linkStyles = getLinkStyles(isDark);
132132
const linkHoverStyles = getLinkHoverStyles(isDark);
133133

134-
if (target === '_self' && !href.startsWith('#')) {
134+
if (target === '_self' && !href.startsWith('#') || href.startsWith('/')) {
135+
const passedStyle = Array.isArray(style) ? StyleSheet.flatten(style) : style;
135136
return (
136137
<Link
137-
{...rest}
138138
href={href}
139139
style={{
140140
...linkStyles,
141141
...(isHovered && linkHoverStyles),
142-
...(style as any),
142+
...passedStyle as any,
143143
...(isHovered && hoverStyle),
144144
}}>
145145
{children}
@@ -152,8 +152,8 @@ export const A = ({ href, target = '_blank', children, style, hoverStyle, ...res
152152
<HtmlElements.A
153153
{...rest}
154154
href={href}
155-
target={target}
156-
hrefAttrs={{ target }}
155+
target={target ?? '_blank'}
156+
hrefAttrs={{ target: target ?? '_blank' }}
157157
style={[linkStyles, isHovered && linkHoverStyles, style, isHovered && hoverStyle]}>
158158
{children}
159159
</HtmlElements.A>

components/Library/TrendingMark.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const TrendingMark = ({ library, style, markOnly = false }: Props) => {
3232
styles.popularityScore,
3333
{
3434
color: popularityStyles.backgroundColor,
35-
marginBottom: markOnly ? 0 : 6,
35+
marginVertical: markOnly ? -1 : 2,
3636
fontSize: markOnly ? 15 : 12,
3737
},
3838
]}>
@@ -119,8 +119,9 @@ const styles = StyleSheet.create({
119119
scoringLink: {
120120
textDecorationLine: 'none',
121121
position: 'relative',
122-
lineHeight: 18,
123122
backgroundColor: 'none',
123+
display: 'flex',
124+
alignItems: 'flex-start',
124125
},
125126
});
126127

0 commit comments

Comments
 (0)