Family Frontend Meetup #2
13 minutes
Frontend
Sep 26, 2023
15 minutes
container: cart-popup-container / inline-size;
@container cart-popup-container (width < 475px) {
color: black;
font-size: 14;
}
Main points:
calc([min font-size] + ([max font-size] - [min font-size]) * ((curr viewport width - [min viewport width]) / ([max viewport width] - [min viewport width])));
html {
font-size: 10px;
@media only screen and (min-width: 1113px) and (max-width: 1440px) {
font-size: calc(6.5px + 3.5 * ((100vw - 1113px) / (1440 - 1113)));
}
@media only screen and (min-width: 835px) and (max-width: 1112px) {
font-size: calc(7.5px + 2.5 * ((100vw - 835px) / (1112 - 835)));
}
@media only screen and (max-width: 834px) {
font-size: calc(10px + 1.5 * ((100vw - 375px) / (834 - 375)));
}
}
body {
font-size: 1.6rem;
}
interface ServiceParams {
sessionToken: CookieValueTypes;
}
export type AsyncThunkApi = {
rejectValue: T;
state: AppState;
};
export type AsyncThunkCachedResponse = {
data: T;
key: string;
};
export const fetchNews = createAsyncThunk<
AsyncThunkCachedResponse,
ServiceParams,
AsyncThunkApi
>(
'catalog/fetchNews',
async (thunkParams, thunkApi) => {
const { rejectWithValue, dispatch, getState } = thunkApi;
try {
// your logic…
} catch (e) {
return rejectWithValue(String(e));
}
},
{
condition: (thunkParams, thunkApi) => {
const { getState } = thunkApi;
const key = JSON.stringify(thunkParams);
const news = getNewsByKey(getState().news, key);
if (news) {
return false;
}
},
}
);