Telegram Group & Telegram Channel
После того как я погрузился в возможности container queries, container units, а также fluid-типографику с clamp() и minmax(), возник вопрос:
а можно ли вообще избавиться от флагов, пропсов и хуков в React-компонентах, которые отвечают за адаптивность?

Зачем каждый раз писать isMobile, size, compact, dense, fullWidth, вызывать хук для определения ширины экрана, если можно описать поведение компонента сразу через CSS и дать ему возможность адаптироваться к размеру своего контейнера?

Это размышление постараюсь разбить в небольшую серию постов, где я исследую, как убрать всю эту логику из JS и сделать компоненты по-настоящему контекстными и адаптивными.

Вот с чего обычно всё начинается:
function ProductCard({ product, isMobile }) {
return (
<Card size={isMobile ? 'compact' : 'full'}>
<Image src={product.image} size={isMobile ? 'small' : 'large'} />
<Title fontSize={isMobile ? '16px' : '24px'}>{product.name}</Title>
{!isMobile && <Description>{product.description}</Description>}
<Price>{product.price}</Price>
<Button size={isMobile ? 'xs' : 'md'}>Купить</Button>
</Card>
);
}

К чему хочется прийти (css modules не обязательно, будем пробовать tailwind-variants, headless решения, какой-нибудь react-aria-components)
function ProductCard({ product }) {
return (
<div className="product-card-container">
<Card className="product-card">
<Image src={product.image} />
<div className="product-info">
<Title className="product-title">{product.name}</Title>
<Description className="product-description">{product.description}</Description>
<Price className="product-price">{product.price}</Price>
<Button className="buy-button">Купить</Button>
</div>
</Card>
</div>
);
}
👍111



group-telegram.com/parrotontheweb/496
Create:
Last Update:

После того как я погрузился в возможности container queries, container units, а также fluid-типографику с clamp() и minmax(), возник вопрос:
а можно ли вообще избавиться от флагов, пропсов и хуков в React-компонентах, которые отвечают за адаптивность?

Зачем каждый раз писать isMobile, size, compact, dense, fullWidth, вызывать хук для определения ширины экрана, если можно описать поведение компонента сразу через CSS и дать ему возможность адаптироваться к размеру своего контейнера?

Это размышление постараюсь разбить в небольшую серию постов, где я исследую, как убрать всю эту логику из JS и сделать компоненты по-настоящему контекстными и адаптивными.

Вот с чего обычно всё начинается:

function ProductCard({ product, isMobile }) {
return (
<Card size={isMobile ? 'compact' : 'full'}>
<Image src={product.image} size={isMobile ? 'small' : 'large'} />
<Title fontSize={isMobile ? '16px' : '24px'}>{product.name}</Title>
{!isMobile && <Description>{product.description}</Description>}
<Price>{product.price}</Price>
<Button size={isMobile ? 'xs' : 'md'}>Купить</Button>
</Card>
);
}

К чему хочется прийти (css modules не обязательно, будем пробовать tailwind-variants, headless решения, какой-нибудь react-aria-components)
function ProductCard({ product }) {
return (
<div className="product-card-container">
<Card className="product-card">
<Image src={product.image} />
<div className="product-info">
<Title className="product-title">{product.name}</Title>
<Description className="product-description">{product.description}</Description>
<Price className="product-price">{product.price}</Price>
<Button className="buy-button">Купить</Button>
</div>
</Card>
</div>
);
}

BY 🦜 on the web


Warning: Undefined variable $i in /var/www/group-telegram/post.php on line 260

Share with your friend now:
group-telegram.com/parrotontheweb/496

View MORE
Open in Telegram


Telegram | DID YOU KNOW?

Date: |

Elsewhere, version 8.6 of Telegram integrates the in-app camera option into the gallery, while a new navigation bar gives quick access to photos, files, location sharing, and more. Lastly, the web previews of t.me links have been given a new look, adding chat backgrounds and design elements from the fully-features Telegram Web client. DFR Lab sent the image through Microsoft Azure's Face Verification program and found that it was "highly unlikely" that the person in the second photo was the same as the first woman. The fact-checker Logically AI also found the claim to be false. The woman, Olena Kurilo, was also captured in a video after the airstrike and shown to have the injuries. But the Ukraine Crisis Media Center's Tsekhanovska points out that communications are often down in zones most affected by the war, making this sort of cross-referencing a luxury many cannot afford. Crude oil prices edged higher after tumbling on Thursday, when U.S. West Texas intermediate slid back below $110 per barrel after topping as much as $130 a barrel in recent sessions. Still, gas prices at the pump rose to fresh highs.
from in


Telegram 🦜 on the web
FROM American