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: |

The regulator said it has been undertaking several campaigns to educate the investors to be vigilant while taking investment decisions based on stock tips. Meanwhile, a completely redesigned attachment menu appears when sending multiple photos or vides. Users can tap "X selected" (X being the number of items) at the top of the panel to preview how the album will look in the chat when it's sent, as well as rearrange or remove selected media. Telegram Messenger Blocks Navalny Bot During Russian Election The channel appears to be part of the broader information war that has developed following Russia's invasion of Ukraine. The Kremlin has paid Russian TikTok influencers to push propaganda, according to a Vice News investigation, while ProPublica found that fake Russian fact check videos had been viewed over a million times on Telegram. Since its launch in 2013, Telegram has grown from a simple messaging app to a broadcast network. Its user base isn’t as vast as WhatsApp’s, and its broadcast platform is a fraction the size of Twitter, but it’s nonetheless showing its use. While Telegram has been embroiled in controversy for much of its life, it has become a vital source of communication during the invasion of Ukraine. But, if all of this is new to you, let us explain, dear friends, what on Earth a Telegram is meant to be, and why you should, or should not, need to care.
from sg


Telegram 🦜 on the web
FROM American