基金会
守护神的地基就是我们所有视觉设计都是从这些地基上构建的原子. 它们打算与情感等CSS-in-JS图书馆一起使用.
安装
$ yarn add @guardian/src-foundations
使用
调色板
import { background } from '@guardian/src-foundations/palette';
const backgroundColor = css`
background-color: ${background.primary};
`;
类型
import { headline, body, textSans } from '@guardian/src-foundations/typography';
const h1 = css`
${headline.large({ fontWeight: 'bold' })};
`;
const p = css`
${body.main()};
`;
const copyright = css`
${textSans.xsmall()};
`;
媒体查询
import { from, until, between } from '@guardian/src-foundations/mq';
const styles = css`
padding: 0 10px;
${from.mobileLandscape} {
padding: 0 20px;
}
${between.phablet.and.desktop} {
padding: 0 32px;
}
${until.wide} {
padding: 0 40px;
}
`;
大小
import { width, height } from '@guardian/src-foundations/size';
const checkbox = css`
width: ${width.inputXsmall}px;
height: ${height.inputXsmall}px;
`;
可视隐藏
对于不应在视觉用户看来,但对辅助技术用户有用的元素.
import { visuallyHidden } from '@guardian/src-foundations/accessibility';
const label = css`
${visuallyHidden};
`;
聚焦光环
此混音提供了 明确焦点状态 用于可能获得键盘焦点的元素.
import { focusHalo } from '@guardian/src-foundations/accessibility';
const input = css`
${focusHalo};
width: 200px;
height: 44px;
`;
说明 Id
使用元素的标识并生成新标识的函数。 这应定为
描述第一个元素的元素的标识 。 生成的ID也应传递给
页:1 aria-describedby 属性.
import { descriptionId } from '@guardian/src-foundations/accessibility';
const Form = () => {
const id = 'first_name';
return (
<form>
<input id={id} type="text" aria-describedby={descriptionId(id)} />
<p class="error" id={descriptionId(id)} />
</form>
);
};