move aspect ratio to atom

This commit is contained in:
Samuel Newman
2025-10-09 13:56:32 +03:00
parent d68fc78e93
commit 976637be31
12 changed files with 31 additions and 19 deletions
+2 -2
View File
@@ -330,7 +330,7 @@ function ExternalEmbed({
{content.external.thumb && ( {content.external.thumb && (
<img <img
src={content.external.thumb} src={content.external.thumb}
className="aspect-[1.91/1] object-cover" className="aspect-[1200/630] object-cover"
/> />
)} )}
<div className="py-3 px-4"> <div className="py-3 px-4">
@@ -435,7 +435,7 @@ function StarterPackEmbed({
<Link <Link
href={starterPackHref} href={starterPackHref}
className="w-full rounded-xl overflow-hidden border dark:border-slate-600 flex flex-col items-stretch"> className="w-full rounded-xl overflow-hidden border dark:border-slate-600 flex flex-col items-stretch">
<img src={imageUri} className="aspect-[1.91/1] object-cover" /> <img src={imageUri} className="aspect-[1200/630] object-cover" />
<div className="py-3 px-4"> <div className="py-3 px-4">
<div className="flex space-x-2 items-center"> <div className="flex space-x-2 items-center">
<img src={starterPackIcon} className="w-10 h-10" /> <img src={starterPackIcon} className="w-10 h-10" />
+12 -1
View File
@@ -1,6 +1,7 @@
import {type StyleProp, type ViewStyle} from 'react-native' import {type StyleProp, type ViewStyle} from 'react-native'
import {atoms as baseAtoms} from '@bsky.app/alf' import {atoms as baseAtoms} from '@bsky.app/alf'
import {CARD_ASPECT_RATIO} from '#/lib/constants'
import {native, platform, web} from '#/alf/util/platform' import {native, platform, web} from '#/alf/util/platform'
import * as Layout from '#/components/Layout' import * as Layout from '#/components/Layout'
@@ -31,6 +32,16 @@ export const atoms = {
backgroundColor: 'transparent', backgroundColor: 'transparent',
}, },
/**
* Aspect ratios
*/
aspect_square: {
aspectRatio: 1,
},
aspect_card: {
aspectRatio: CARD_ASPECT_RATIO,
},
/* /*
* Transition * Transition
*/ */
@@ -67,7 +78,7 @@ export const atoms = {
}), }),
/* /*
* Animaations * Animations
*/ */
fade_in: web({ fade_in: web({
animation: 'fadeIn ease-out 0.15s', animation: 'fadeIn ease-out 0.15s',
+2 -2
View File
@@ -258,7 +258,7 @@ export function InterestTabs({
t.atoms.border_contrast_low, t.atoms.border_contrast_low,
t.atoms.bg, t.atoms.bg,
a.h_full, a.h_full,
{aspectRatio: 1}, a.aspect_square,
a.rounded_full, a.rounded_full,
]}> ]}>
<ButtonIcon icon={ArrowLeft} /> <ButtonIcon icon={ArrowLeft} />
@@ -292,7 +292,7 @@ export function InterestTabs({
t.atoms.border_contrast_low, t.atoms.border_contrast_low,
t.atoms.bg, t.atoms.bg,
a.h_full, a.h_full,
{aspectRatio: 1}, a.aspect_square,
a.rounded_full, a.rounded_full,
]}> ]}>
<ButtonIcon icon={ArrowRight} /> <ButtonIcon icon={ArrowRight} />
+3 -2
View File
@@ -87,7 +87,7 @@ export function ImageItem({
}) { }) {
const t = useTheme() const t = useTheme()
return ( return (
<View style={[a.relative, a.flex_1, {aspectRatio: 1, maxWidth: 100}]}> <View style={[a.relative, a.flex_1, a.aspect_square, {maxWidth: 100}]}>
<Image <Image
key={thumbnail} key={thumbnail}
source={{uri: thumbnail}} source={{uri: thumbnail}}
@@ -131,7 +131,8 @@ export function VideoItem({
style={[ style={[
{backgroundColor: 'black'}, {backgroundColor: 'black'},
a.flex_1, a.flex_1,
{aspectRatio: 1, maxWidth: 100}, a.aspect_square,
{maxWidth: 100},
a.justify_center, a.justify_center,
a.align_center, a.align_center,
]}> ]}>
@@ -97,9 +97,7 @@ export const ExternalEmbed = ({
]}> ]}>
{imageUri && !embedPlayerParams ? ( {imageUri && !embedPlayerParams ? (
<Image <Image
style={{ style={[a.aspect_card]}
aspectRatio: 1.91,
}}
source={{uri: imageUri}} source={{uri: imageUri}}
accessibilityIgnoresInvertColors accessibilityIgnoresInvertColors
/> />
+1 -1
View File
@@ -91,8 +91,8 @@ function ShareDialogInner({
source={{uri: imageUrl}} source={{uri: imageUrl}}
style={[ style={[
a.rounded_sm, a.rounded_sm,
a.aspect_card,
{ {
aspectRatio: 1200 / 630,
transform: [{scale: gtMobile ? 0.85 : 1}], transform: [{scale: gtMobile ? 0.85 : 1}],
marginTop: gtMobile ? -20 : 0, marginTop: gtMobile ? -20 : 0,
}, },
@@ -191,7 +191,7 @@ export function Embed({
<Link starterPack={starterPack}> <Link starterPack={starterPack}>
<Image <Image
source={imageUri} source={imageUri}
style={[a.w_full, {aspectRatio: 1.91}]} style={[a.w_full, a.aspect_card]}
accessibilityIgnoresInvertColors={true} accessibilityIgnoresInvertColors={true}
/> />
<View style={[a.px_sm, a.py_md]}> <View style={[a.px_sm, a.py_md]}>
+2 -1
View File
@@ -300,7 +300,8 @@ export function GifPreview({
a.flex_1, a.flex_1,
a.mb_sm, a.mb_sm,
a.rounded_sm, a.rounded_sm,
{aspectRatio: 1, opacity: pressed ? 0.8 : 1}, a.aspect_card,
{opacity: pressed ? 0.8 : 1},
t.atoms.bg_contrast_25, t.atoms.bg_contrast_25,
]} ]}
source={{ source={{
+1 -1
View File
@@ -102,7 +102,7 @@ export function LiveStatus({
style={[ style={[
t.atoms.bg_contrast_25, t.atoms.bg_contrast_25,
a.w_full, a.w_full,
{aspectRatio: 1.91}, a.aspect_card,
android([ android([
a.overflow_hidden, a.overflow_hidden,
{ {
+1
View File
@@ -17,6 +17,7 @@ export const EMBED_SERVICE = 'https://embed.bsky.app'
export const EMBED_SCRIPT = `${EMBED_SERVICE}/static/embed.js` export const EMBED_SCRIPT = `${EMBED_SERVICE}/static/embed.js`
export const BSKY_DOWNLOAD_URL = 'https://bsky.app/download' export const BSKY_DOWNLOAD_URL = 'https://bsky.app/download'
export const STARTER_PACK_MAX_SIZE = 150 export const STARTER_PACK_MAX_SIZE = 150
export const CARD_ASPECT_RATIO = 1200 / 630
// HACK // HACK
// Yes, this is exactly what it looks like. It's a hard-coded constant // Yes, this is exactly what it looks like. It's a hard-coded constant
+1 -1
View File
@@ -401,7 +401,7 @@ function ValueProposition({
]}> ]}>
<Image <Image
source={image} source={image}
style={[a.w_full, {aspectRatio: 1}]} style={[a.w_full, a.aspect_square]}
alt={alt} alt={alt}
accessibilityIgnoresInvertColors={false} // I guess we do need it to blend into the background accessibilityIgnoresInvertColors={false} // I guess we do need it to blend into the background
/> />
+4 -4
View File
@@ -67,7 +67,7 @@ function ImageLayoutGridInner(props: ImageLayoutGridInnerProps) {
const containerRefs = [containerRef1, containerRef2] const containerRefs = [containerRef1, containerRef2]
return ( return (
<View style={[a.flex_1, a.flex_row, gap]}> <View style={[a.flex_1, a.flex_row, gap]}>
<View style={[a.flex_1, {aspectRatio: 1}]}> <View style={[a.flex_1, a.aspect_square]}>
<GalleryItem <GalleryItem
{...props} {...props}
index={0} index={0}
@@ -76,7 +76,7 @@ function ImageLayoutGridInner(props: ImageLayoutGridInnerProps) {
thumbDimsRef={thumbDimsRef} thumbDimsRef={thumbDimsRef}
/> />
</View> </View>
<View style={[a.flex_1, {aspectRatio: 1}]}> <View style={[a.flex_1, a.aspect_square]}>
<GalleryItem <GalleryItem
{...props} {...props}
index={1} index={1}
@@ -93,7 +93,7 @@ function ImageLayoutGridInner(props: ImageLayoutGridInnerProps) {
const containerRefs = [containerRef1, containerRef2, containerRef3] const containerRefs = [containerRef1, containerRef2, containerRef3]
return ( return (
<View style={[a.flex_1, a.flex_row, gap]}> <View style={[a.flex_1, a.flex_row, gap]}>
<View style={[a.flex_1, {aspectRatio: 1}]}> <View style={[a.flex_1, a.aspect_square]}>
<GalleryItem <GalleryItem
{...props} {...props}
index={0} index={0}
@@ -102,7 +102,7 @@ function ImageLayoutGridInner(props: ImageLayoutGridInnerProps) {
thumbDimsRef={thumbDimsRef} thumbDimsRef={thumbDimsRef}
/> />
</View> </View>
<View style={[a.flex_1, {aspectRatio: 1}, gap]}> <View style={[a.flex_1, a.aspect_square, gap]}>
<View style={[a.flex_1]}> <View style={[a.flex_1]}>
<GalleryItem <GalleryItem
{...props} {...props}