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

In February 2014, the Ukrainian people ousted pro-Russian president Viktor Yanukovych, prompting Russia to invade and annex the Crimean peninsula. By the start of April, Pavel Durov had given his notice, with TechCrunch saying at the time that the CEO had resisted pressure to suppress pages criticizing the Russian government. Again, in contrast to Facebook, Google and Twitter, Telegram's founder Pavel Durov runs his company in relative secrecy from Dubai. Messages are not fully encrypted by default. That means the company could, in theory, access the content of the messages, or be forced to hand over the data at the request of a government. At its heart, Telegram is little more than a messaging app like WhatsApp or Signal. But it also offers open channels that enable a single user, or a group of users, to communicate with large numbers in a method similar to a Twitter account. This has proven to be both a blessing and a curse for Telegram and its users, since these channels can be used for both good and ill. Right now, as Wired reports, the app is a key way for Ukrainians to receive updates from the government during the invasion. Markets continued to grapple with the economic and corporate earnings implications relating to the Russia-Ukraine conflict. “We have a ton of uncertainty right now,” said Stephanie Link, chief investment strategist and portfolio manager at Hightower Advisors. “We’re dealing with a war, we’re dealing with inflation. We don’t know what it means to earnings.”
from pl


Telegram 🦜 on the web
FROM American