aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/layout_cookbook/contribute_a_recipe
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/css/layout_cookbook/contribute_a_recipe
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/css/layout_cookbook/contribute_a_recipe')
-rw-r--r--files/zh-cn/web/css/layout_cookbook/contribute_a_recipe/index.html91
1 files changed, 91 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/layout_cookbook/contribute_a_recipe/index.html b/files/zh-cn/web/css/layout_cookbook/contribute_a_recipe/index.html
new file mode 100644
index 0000000000..37ceeddd92
--- /dev/null
+++ b/files/zh-cn/web/css/layout_cookbook/contribute_a_recipe/index.html
@@ -0,0 +1,91 @@
+---
+title: Contribute a recipe
+slug: Web/CSS/Layout_cookbook/Contribute_a_recipe
+translation_of: Web/CSS/Layout_cookbook/Contribute_a_recipe
+---
+<div>{{CSSRef}}</div>
+
+<p class="summary">如果您愿意为 Layout Cookbook 贡献示例文件,那么本页将通过阐释步骤指导您发布示例。</p>
+
+<h2 id="好的_recipe_是怎样的">好的 recipe 是怎样的?</h2>
+
+<p><strong>任何有用的 web 设计模式的最简版本。</strong>您 CSS 文件中的每一行代码都应该有助于演示该模式, 省去无用的部分就是为了能让示例显得完美。这种想法就是,某个人既能将这种模式应用在网站中,又可以保持自己的风格。</p>
+
+<h2 id="发布_recipe_的步骤">发布 recipe 的步骤</h2>
+
+<p>一份 recipe 包括以下内容:</p>
+
+<ol>
+ <li>一个动态的示例,存储在 <a href="https://github.com/mdn/css-examples">CSS Examples GitHub repo</a> 之上。</li>
+ <li>这份示例的可供下载版本,同样也存储在 CSS Examples repo 之上。</li>
+ <li>该网站的某个页面在 <a href="/en-US/docs/Web/CSS/Layout_cookbook">CSS layout cookbook</a> 上应详细说明:
+ <ol>
+ <li>要求</li>
+ <li>recipe</li>
+ <li>做出的选择</li>
+ <li>任何有用的反馈或供选择的方法</li>
+ <li>任何无障碍访问问题</li>
+ <li>浏览器兼容性</li>
+ <li>其他资源</li>
+ </ol>
+ </li>
+</ol>
+
+<h3 id="1._建立自己的模式">1. 建立自己的模式</h3>
+
+<p>在将示例转换为 recipe 之前,先将您的模式创建成为一个简单的 HTML 页面。想想看您要展示的是什么,并使这个想法尽可能简单。避免使用特殊的 CSS 约定(例如 BEM),因为并非每个人都熟悉这些约定,反而会使他们将事情做得看起来要比预期中的更复杂。</p>
+
+<p>确保 HTML 和 CSS 有效,并将其在一种以上的浏览器上进行测试。如果您使用的 CSS 属性并非广受支持,那也没关系!您可以在创建页面时包含浏览器支持信息。在某些情况下,创建示例的第二个版本可能会有帮助,其中包括回退支持。</p>
+
+<h3 id="2._创建一个动态示例">2. 创建一个动态示例</h3>
+
+<p>The live examples that you can see on cookbook pages and elsewhere on MDN allow visitors to play with the code and change relevant parts without being overwhelmed with all of the code needed. You recipe will be demonstrated by way of one or more examples.</p>
+
+<p>Fork the <a href="https://github.com/mdn/css-examples">CSS Examples repo</a> and then take a look in the <code>css-cookbook</code> folder. There is a <a href="https://github.com/mdn/css-examples/blob/master/css-cookbook/cookbook-template.html">cookbook-template.html</a> file you can copy as a starting point. Save this in the css-cookbook directory with a name that makes sense for your pattern. The template is commented to help you add the various parts to the right place.</p>
+
+<p>The important parts of this are as follows.</p>
+
+<p>There is a stylesheet for styles for the editor panels, and some basic body styling, and a JavaScript file included for the editor functionality. Leave these files as they are.</p>
+
+<p>There are two style blocks in the head. The first are for things that a visitor to the page does not need to change to play with the example. The second is for any of the items they might want to play with in the live example. We typically add all of our CSS from like example in the first block, then choose which sets of rules we need to move down to the second block. The rules in the second block should be those that are fundamental to the pattern, perhaps those where a user could make a change to a CSS value and see the pattern update.</p>
+
+<p>You need to add the HTML for your component twice. First inside the section with a class of preview, then inside the textarea <code>playable-html</code>.</p>
+
+<p>Your editable CSS, from the second block in the head, also needs to be copied into the <code>playable-css</code> section.</p>
+
+<p>A simple worked example is <a href="https://github.com/mdn/css-examples/blob/master/css-cookbook/center.html">center.html</a>, which is embedded on the page <a href="/en-US/docs/user:chrisdavidmills/Layout_Cookbook_Home/Center_an_element">Center an element</a>. You can use this to see how to add the various bits correctly.</p>
+
+<p>If you have forked the repo and therefore have our CSS and JavaScript files alongside your example, if you open up your live example in the browser you should see everything working exactly as it will when included in a page.</p>
+
+<h4 id="Useful_tips">Useful tips</h4>
+
+<ol>
+ <li>Do not indent the CSS and HTML inside the textareas; instead bump it up against the start of the lines. This will look better when it is rendered.</li>
+ <li>If you have any required images, pop them into the directory with the examples. Or you are welcome to use any already there.</li>
+ <li>You can adjust the height of the textareas by changing the height in the inline styles.</li>
+</ol>
+
+<h3 id="3._创建一份可供下载的版本">3. 创建一份可供下载的版本</h3>
+
+<p>As the examples include all of our live example code, we want to offer visitors a simple example without all of that included. Make a copy of your live example with --download appended. For example, center.html, has a download version named <code>center--download.html</code>. This file will be similar to your initial example. It should be a basic version of your pattern as a single HTML page. It can be handy to include the body CSS rules that are in our included stylesheet, if you take a look at <a href="https://github.com/mdn/css-examples/blob/master/css-cookbook/cookbook-template--download.html">cookbook-template--download.html</a>, these are included as a starting point.</p>
+
+<h3 id="4._用您的示例发起_Pull_请求">4. 用您的示例发起 Pull 请求</h3>
+
+<p>Make a PR on the <a href="https://github.com/mdn/css-examples">CSS Examples repo</a>. This way we can help you with any changes to the example that may be needed before you create your page, plus the example will need to be live to be included some it makes sense to create it first. Include in your PR an explanation of the pattern and what you are demonstrating.</p>
+
+<h3 id="5._创建您的页面">5. 创建您的页面</h3>
+
+<p>Once your example is merged you can create your page. You will need an MDN account to do so with <a href="https://developer.mozilla.org/en-US/docs/MDN/Contribute/Howto/Create_and_edit_pages#Getting_page_creation_permissions">page creation permissions</a>, and you can then create the page as a subpage of the CSS Cookbook page. <a href="/en-US/docs/user:chrisdavidmills/Layout_Cookbook_Home/Contribute_a_recipe/Cookbook_template">There is a template for Cookbook pages here</a>.</p>
+
+<p>The template explains what should be part of each section, and you can refer to other cookbook examples for more help. If you click to edit any of those pages then you will be able to see things such as the macros used to embed compat data, and live examples.</p>
+
+<p>If you need general guidance on using the MDN wiki, see the help pages available here.</p>
+
+<p>If you need to ask any questions, or want someone to take a look at your page then the <a href="https://discourse.mozilla.org/c/mdn">MDN Discourse forum</a> is a good place to do this, or <a href="https://wiki.developer.mozilla.org/en-US/docs/MDN/Community/Conversations#Synchronous_chat">chat with us on Matrix</a>.</p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="/en-US/docs/user:chrisdavidmills/Layout_Cookbook_Home/Contribute_a_recipe/Cookbook_template">Cookbook page template</a></li>
+ <li><a href="https://github.com/mdn/css-examples">CSS Examples repo</a></li>
+</ul>