import { createStyles } from 'antd-style';
const useStyles = createStyles(({ token, css }) => ({
// CSS nesne sözdizimini destekler
container: {
backgroundColor: token.colorBgLayout,
borderRadius: token.borderRadiusLG,
maxWidth: 400,
width: '100%',
height: 180,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexDirection: 'column',
marginLeft: 'auto',
marginRight: 'auto',
},
// Ayrıca, standart CSS ile tutarlı bir yazım deneyimi için CSS dize şablonlarını da destekler.
card: css`
color: ${token.colorTextTertiary};
box-shadow: ${token.boxShadow};
&:hover {
color: ${token.colorTextSecondary};
box-shadow: ${token.boxShadowSecondary};
}
padding: ${token.padding}px;
border-radius: ${token.borderRadius}px;
background: ${token.colorBgContainer};
transition: all 100ms ${token.motionEaseInBack};
margin-bottom: 8px;
cursor: pointer;
`,
}));
export default () => {
// styles nesnesi, useStyles metodunda varsayılan olarak önbelleğe alınır, bu nedenle yeniden render sorunları hakkında endişelenmenize gerek yoktur.
const { styles, cx, theme } = useStyles();
return (
// className'leri düzenlemek için cx kullanın
<div
className={cx('a-simple-create-style-demo-classname', styles.container)}
>
<div className={styles.card}>createStyles Demo</div>
{/* theme nesnesi tüm token'ları ve tema bilgilerini içerir */}
<div>Mevcut tema modu: {theme.appearance}</div>
</div>
);
};