沙姆米德-嵌入物-错误 -

说明
EmbedError 是一个为嵌入内容设计的精益错误信息组件,例如iframe中的内容。 它将填充母容器,并可选择填充取景口,同时相应定位其内容.
安装
npm install @bbc/psammead-embed-error --save
道具
| 参数 | 类型 | 需求 | 默认 | 示例 |
|---|---|---|---|---|
service | 字符串 | 没有 | news | arabic |
fillViewport | 布尔 | 没有 | false | true |
message | 字符串 | 对 | - 说吧 | Sorry, we can't display this content. |
link | 对象 | 没有 | null | 见: 链接。 。 。 . |
link
| 参数 | 类型 | 需求 | 默认 | 示例 |
|---|---|---|---|---|
text | 字符串 | 对 | 无 | View alternate content. |
href | 字符串 | 对 | 无 | https://www.bbc.co.uk/news/av-embed/a-video-about-dogs |
使用量
如果您在 iframe 中服务内容, 并且希望用户有无缝错误体验, 此组件特别有用 。 考虑以下例子:
// An article with an iframe.
<iframe src="https://www.bbc.co.uk/news/av-embed/a-video-about-cats"></iframe>
// iframe content.
import EmbedError from '@bbc/psammead-embed-error';
const Page = () => {
if (error) {
return
<EmbedError
message="Sorry, we can't display this content."
link={{
text: 'View alternate content.',
href: 'https://www.bbc.co.uk/news/article/all-about-dogs',
}}
fillViewport
/>;
}
};
注意使用 fillViewport,可以确保错误将填充文章中的 iframe.
何时使用此组件
当您想要显示填充容器或取景口的错误消息时,应当使用此组件.
不使用此组件时
此组件不应用于显示错误以外的信件 .
无障碍说明
此组件的错误消息被包裹在一个 <strong> 元素,向辅助技术的用户表明这是一种重要信息。 这与媒体玩家的"占位符"中使用的"指导"组件类似.
路线图
预计这一构成部分的所需经费将发生变化。 莫扎特错误报告的发展将影响未来如何(和在何处)使用这个组件.
捐款
Psammead完全开源. 我们感谢任何贡献,无论是新的组件、错误修正还是总体改进。 请参看我们的主要贡献指南,可查阅: psammead 仓库的根。 。 。 .
行为守则
我们欢迎对这项工作的反馈和帮助。 通过参与这个项目,你同意遵守 行为守则请稍候再读一下.
许可证
萨姆米德 Apache 2.0 许可。 。 。 .