Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.

Commit 0d90510

Browse files
committed
translate docs/global-css
1 parent 14341fe commit 0d90510

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

docs/docs/global-css.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
---
2-
title: Standard Styling with Global CSS Files
2+
title: グローバル CSS ファイルを用いた標準的なスタイリング
33
---
44

5-
Traditionally, websites are styled using global CSS files.
5+
古くよりウェブサイトはグローバル CSS ファイルによってスタイリングが行われてきました。
66

7-
Globally-scoped CSS rules are declared in external `.css` stylesheets, and [CSS specificity](https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity) and [the Cascade](https://developer.mozilla.org/en-US/docs/Web/CSS/Cascade) determine how styles are applied.
7+
グローバルスコープ CSS ルールは外部 `.css` ファイルの中で宣言され、 [詳細度](https://developer.mozilla.org/ja/docs/Web/CSS/Specificity) [カスケード処理](https://developer.mozilla.org/ja/docs/Web/CSS/Cascade) によってスタイルの優先順位が決められ、スタイルが適用されます。
88

9-
## Adding global styles with a layout component
9+
## レイアウトコンポーネントにグローバルスタイルを追加する
1010

11-
The best way to add global styles is with a [shared layout component](/tutorial/part-three/#your-first-layout-component). This layout component is used for things that are shared throughout the site, including styles, header components, and other common items.
11+
グローバルスタイルを追加する最善の方法は [共通レイアウトコンポーネント](/tutorial/part-three/-はじめてのレイアウトコンポーネントの作成) を利用することです。レイアウトコンポーネントはサイト共通の部品として使用されます。たとえば、スタイルやヘッダーコンポーネント、そのほか共通で使われる部品が該当します。
1212

13-
> **NOTE:** This pattern is implemented by default in [the default starter](https://github.com/gatsbyjs/gatsby-starter-default/blob/02324e5b04ea0a66d91c7fe7408b46d0a7eac868/src/layouts/index.js#L6).
13+
> **NOTE:** このパターンは Gatsby の [the default starter](https://github.com/gatsbyjs/gatsby-starter-default/blob/02324e5b04ea0a66d91c7fe7408b46d0a7eac868/src/layouts/index.js#L6) の中でデフォルトレイアウトとして実装されています。
1414
15-
To create a shared layout with global styles, start by creating a new Gatsby site with the [hello world starter](https://github.com/gatsbyjs/gatsby-starter-hello-world).
15+
グローバルスタイルを使った共通レイアウトを学ぶために、 まず [hello world starter](https://github.com/gatsbyjs/gatsby-starter-hello-world) を使った新しい Gatsby サイトを作成してください。
1616

1717
```shell
1818
gatsby new global-styles https://github.com/gatsbyjs/gatsby-starter-hello-world
1919
```
2020

21-
Open your new site in your code editor and create a new directory at `/src/components`. Inside, create two new files:
21+
新規作成したサイトをコードエディターで開きます。 `/src/components` ディレクトリーを作成し、新規ファイルを 2 つ作成します:
2222

2323
```diff
2424
global-styles/
@@ -31,7 +31,7 @@ Open your new site in your code editor and create a new directory at `/src/compo
3131
└─ index.js
3232
```
3333

34-
Inside `src/components/layout.css`, add some global styles:
34+
`src/components/layout.css` の中にグローバルスタイルを追加します:
3535

3636
```css:title=src/components/layout.css
3737
div {
@@ -40,7 +40,7 @@ div {
4040
}
4141
```
4242

43-
In `src/components/layout.js`, include the stylesheet and export a layout component:
43+
`src/components/layout.js` の中でスタイルシートを読み込み、レイアウトコンポーネントをエクスポートします:
4444

4545
```jsx:title=src/components/layout.js
4646
import React from "react"
@@ -49,7 +49,7 @@ import "./layout.css"
4949
export default ({ children }) => <div>{children}</div>
5050
```
5151

52-
Finally, update `src/pages/index.js` to use the new layout component:
52+
最後に `src/pages/index.js` を更新して、作成したレイアウトコンポーネントを使用します。
5353

5454
```jsx:title=src/pages/index.js
5555
import React from "react"
@@ -58,25 +58,25 @@ import Layout from "../components/layout"
5858
export default () => <Layout>Hello world!</Layout>
5959
```
6060

61-
Run `npm run develop` and you’ll see the global styles applied.
61+
`npm run develop` を実行するとグローバルスタイルが適用されていることを確認できます。
6262

6363
![Global styles](./images/global-styles.png)
6464

65-
## Adding global styles without a layout component
65+
## レイアウトコンポーネントを使わずにグローバルスタイルを追加する
6666

67-
In some cases, using a shared layout component is not desirable. In these cases, you can include a global stylesheet using `gatsby-browser.js`.
67+
場合によっては、共通レイアウトコンポーネント使うことは好ましくありません。このような場合では `gatsby-browser.js` を使ってグローバルスタイルを読み込むこともできます。
6868

69-
> **NOTE:** This approach does _not_ work with CSS-in-JS. Use shared components to share styles in CSS-in-JS.
69+
> **NOTE:** このアプローチは CSS-in-JS と同時には動作しません。 共通コンポーネントを使って、CSS-in-JS の中でスタイルを割り当ててください。
7070
71-
First, open a new terminal window and run the following commands to create a new default Gatsby site and start the development server:
71+
はじめに、新しいターミナルウィンドウを開き、下記コマンドを実行して新規に Gatsby サイトを作成し、開発サーバーを起動してください。
7272

7373
```shell
7474
gatsby new global-style-tutorial https://github.com/gatsbyjs/gatsby-starter-default
7575
cd global-style-tutorial
7676
npm run develop
7777
```
7878

79-
Second, create a CSS file and define any styles you wish. An example:
79+
次に、CSS ファイルを作成し、任意の CSS を定義してください。例:
8080

8181
```css:title=src/styles/global.css
8282
html {
@@ -88,10 +88,10 @@ a {
8888
}
8989
```
9090

91-
Then, include the stylesheet in your site's `gatsby-browser.js` file.
91+
そして、`gatsby-browser.js` の中で CSS ファイルを読み込みます。
9292

93-
> **NOTE:** This solution works when including css as those styles are extracted when building the JavaScript but not for css-in-js.
94-
> Including styles in a layout component or a global-styles.js is your best bet for that.
93+
> **NOTE:** この方法は CSS を読み込んだときに実行され、読み込んだスタイルは JavaScript ビルド時に出力されます。 CSS-in-JS のための JavaScript ビルドは行われません。
94+
> レイアウトコンポーネントまたは global-styles.js の中で CSS ファイルを読み込むことが最善策になります。
9595
9696
```javascript:title=gatsby-browser.js
9797
import "./src/styles/global.css"
@@ -100,15 +100,15 @@ import "./src/styles/global.css"
100100
// require('./src/styles/global.css')
101101
```
102102

103-
> _Note: You can use Node.js require or import syntax. Additionally, the placement of the example css file in a `src/styles` folder is arbitrary._
103+
> _Note: Node.js require, import 構文を使うことができます。さらにつけ加えると、 `src/styles` フォルダの中に置く実例 CSS ファイルの配置は任意です。_
104104
105-
You should see your global styles taking effect across your site:
105+
グローバルスタイルがサイト全体に反映されているはずです:
106106

107107
![Global styles example site](./images/global-styles-example.png)
108108

109-
### Importing CSS files into components
109+
### コンポーネントの中で CSS を読み込む
110110

111-
It is also possible to break up your CSS styles into separate files so that team members can work independently while still using traditional CSS. You can then [import files directly](/docs/importing-assets-into-files/) into pages, templates, or components:
111+
チームメンバーが従来の CSS (非 CSS-in-JS)を使用している場合でも、 個別の CSS ファイルに分割し、独立した作業が行えます。[import files directly](/docs/importing-assets-into-files/) を使ってページやテンプレート、コンポーネントの中で CSS を取り込むことで可能にします。
112112

113113
```css:title=menu.css
114114
.menu {
@@ -122,11 +122,11 @@ It is also possible to break up your CSS styles into separate files so that team
122122
import "css/menu.css"
123123
```
124124

125-
This approach can simplify integration of CSS or [Sass](/packages/gatsby-plugin-sass/) styles into your Gatsby site by allowing team members to write and consume more traditional, class-based CSS. However, there are [trade-offs](#limitations) that must be considered with regards to web performance and the lack of dead code elimination.
125+
このアプローチではチームメンバーがより伝統的に使われてきたクラスベースの CSS を使って記述することが可能になり、Gatsby サイトの中で CSS や Sass 記法の統合が簡単に実現できます。ただし、ウェブパフォーマンスや不要になったコードの除去を忘れる事について考えなければならなくなるトレードオフがあります。
126126

127-
### Adding classes to components
127+
### コンポーネントに CSS クラスを追加する
128128

129-
Since `class` is a reserved word in JavaScript, you'll have to use the `className` prop instead, which will render as the browser-supported `class` attribute in your HTML output.
129+
`class` JavaScript において予約語なので、代わりに `className` 属性を使わなければなりません。 HTML に出力されるとブラウザサポートされた `class` 属性としてレンダリングされます。
130130

131131
```jsx
132132
<button className="primary">Click me</button>
@@ -138,8 +138,8 @@ Since `class` is a reserved word in JavaScript, you'll have to use the `classNam
138138
}
139139
```
140140

141-
### Limitations
141+
### 問題解決の限界
142142

143-
The biggest problem with global CSS files is the risk of name conflicts and side effects like unintended inheritance.
143+
グローバル CSS ファイルのもっとも大きな問題は名前が衝突するリスクと、意図しない継承の影響を受けてしまうことです。
144144

145-
CSS methodologies like BEM can help solve this, but a more modern solution is to write locally-scoped CSS using [CSS Modules](/docs/css-modules/) or [CSS-in-JS](/docs/css-in-js/).
145+
この問題を解決するための助けとして BEM のような CSS 設計がありますが、より現代的な解決策は [CSS Modules](/docs/css-modules/) [CSS-in-JS](/docs/css-in-js/) を使用したローカルスコープの CSS を記述することです。

0 commit comments

Comments
 (0)