SlideShare a Scribd company logo
Gutenberg Handbook

をみんなで読んでみよう
presented by mimi
2019-03-26
About me
mimi
@miminari
web好きなしゅふです。
WordPress歴は10年余。
イラスト描いたりもします。
Gutenberg Handbook とは
公式が書いているGutenbergの教科書



https://wordpress.org/gutenberg/
handbook/



これをGoogle翻訳に突っ込んで読めば
大体わかります。



以上
Gutenberg Handbook とは
…なのですが、
かなりボリュームがあって
私もほとんど読めてません。
折角なので今日はちょっとだけ
一緒に読んでみたいと思います。
Theming for Gutenberg
一番取っ掛かりやすそうな

Gutenbergのためのテーマ作り

というセクションを読んでみたい

と思います。
ハンドブックが開ける方は

https://wordpress.org/gutenberg/handbook/
designers-developers/developers/themes/

を一緒に御覧くださいね。
既読・ガチ勢はフォローお願いします。
Theming for Gutenberg
ココのセクションは
“Theme Support” の1ページだけ!
この1ページを読めば、

今使ってるテーマをどうやって
Gutenberg対応したら良いか

が丸わかりです!
Theme Support の5つのコンセプト
1. エディタのカラーパレット
2. エディタのテキストサイズパレット
3. フロントエンドとエディタのスタイル
4. 埋め込み要素のレスポンシブ化
5. ダークモード
TT
対応するべき
やったほうがいい
ケースバイケース
mimiのオススメ度別
Editor Color Palette
Gutenbergではデフォルトの色の
セット(カラーパレット)が提供
されています。
テーマ毎に、

このカラーパレットへ

独自の色を登録できます。
Editor Color Palette
公式テーマは対応済みです。

例えば最新のTwenty Nineteen
ではテーマに合わせた右のような

5色が出るようになっています。
色数は好きな数に設定できます。
たぶん、カバー画像のフィルター
色とかボタンの色とかでの使用頻
度高い気がします。
カラーパレットの設定方法
add_theme_support



の ’editor-color-palette’

を使います。
functions.php に右のソースを参考
に書き足(コピぺ)して、指定したい
色のname, slug, colorを設定して
いけば OK!
function mytheme_setup_theme_supported_features() {
add_theme_support( 'editor-color-palette', array(
array(
'name' => __( 'strong magenta', 'themeLangDomain' ),
'slug' => 'strong-magenta',
'color' => '#a156b4',
),
array(
'name' => __( 'light grayish magenta', 'themeLangDomain' ),
'slug' => 'light-grayish-magenta',
'color' => '#d0a5db',
),
array(
'name' => __( 'very light gray', 'themeLangDomain' ),
'slug' => 'very-light-gray',
'color' => '#eee',
),
array(
'name' => __( 'very dark gray', 'themeLangDomain' ),
'slug' => 'very-dark-gray',
'color' => '#444',
),
) );
}
add_action( 'after_setup_theme',
'mytheme_setup_theme_supported_features' );
Handbookのソースのそのままです。
一色分
ちょっとだけPHP
カラーパレットの設定方法(実例)
試しに Twenty Nineteen
の子テーマを作って、

色を上書きしてみましょう。
3つの色を設定してみました。
function setup_color_pallette_for_19child() {
add_theme_support( 'editor-color-palette', array(
array(
'name' => 'メインカラー',
'slug' => 'primary',
'color' => '#CE2121',
),
array(
'name' => 'サブカラー',
'slug' => 'secondary',
'color' => '#988768',
),
array(
'name' => '背景用',
'slug' => 'background',
'color' => '#000',
)
) );
}
add_action( 'after_setup_theme', 'setup_color_pallette_for_19child' ,11);
priorityを11にするのが唯一の肝。
カラーパレットの設定方法(実例)
こんな感じに好きな色に変更
できます!かんたん!
公開ページ側の設定を忘れずに
ただし、

別途CSSの設定をしないと、

公開したページには

色が反映されません

のでご注意を!
/* 

.has-(設定したスラッグ名)-colorと
.has-(設定したスラッグ名)-background-color

の色を設定する必要があります。
*/


.entry .entry-content .has-primary-background-color {
background-color: #CE2121;
}
.entry .entry-content .has-primary-color {
color: #CE2121;
}
公開ページ側の設定を忘れずに
style.cssに追記することで
公開ページのスタイルにも
反映されます。
Editor Text Size Palette
Gutenbergではテキストサイズもいくつ
か選択できるようになっています。
これもテーマごとに

変更できます。
TT
テキストサイズパレットの設定方法
add_theme_support



の ’editor-font-sizes’

を使います。
functions.php に右のソースを参考
に書き足(コピぺ)して、指定したい
色のname, size, slugを設定してい
けば OK!
add_theme_support( 'editor-font-sizes', array(
array(
'name' => __( 'Small', 'themeLangDomain' ),
'size' => 12,
'slug' => 'small'
),
array(
'name' => __( 'Normal', 'themeLangDomain' ),
'size' => 16,
'slug' => 'normal'
),
array(
'name' => __( 'Large', 'themeLangDomain' ),
'size' => 36,
'slug' => 'large'
),
array(
'name' => __( 'Huge', 'themeLangDomain' ),
'size' => 50,
'slug' => 'huge'
)
) );
TT
実例で見てみよう
文字のサイズだけでなく
表示名も数も変更できます。
TT
テキストサイズもstyle.cssの設定が必要です
style.cssの設定をしないと、

公開したページには

フォントサイズが反映されません

のでご注意を!
/* 

.has-(設定したスラッグ名)-font-size

のサイズを設定する必要があります。
*/


.entry .entry-content .has-large-font-size {
font-size: 36px;
}
TT
テキストサイズの数値指定をオフにする
テキストサイズの数値指定も

オフにできます。
add_theme_support( 'disable-custom-font-sizes' );
TT
Frontend & Editor Styles
エディター側のスタイルを

フロント側(公開されたページ側)に
合わせることが出来ます。
ほぼプレビュー状態で編集できるのは
使い勝手が良くなるのでなるべく対応
したほうが良いです。
まずは実際にCSSを書かなくても良い
ので設定だけでもやっておくのをオス
スメします。
エディタースタイルの設定方法
テーマに合わせた

エディタースタイルを設定するには
同様に、functions.phpに
add_theme_support。

そして、add_editor_styleで
CSSファイルを指定すればエディター
画面に読み込まれます。
// Add support for editor styles.
add_theme_support( 'editor-styles' );
// Enqueue editor styles.
add_editor_style( 'style-editor.css' );
実例で見てみよう
フロント側と書体や文字サイズを

合わせてみました。
That’s all for today!
残りの2つについては
自分で読み解いてみてください!
今回の適当サンプルソースは
Twenty Nineteenの子テーマの形で
GitHubにアップしていますので
良かったらご参照ください。
https://github.com/miminari/19childja

More Related Content

Featured

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
GetSmarter
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
Alireza Esmikhani
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
Project for Public Spaces & National Center for Biking and Walking
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
Erica Santiago
 

Featured (20)

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 

Gutenberg Handbookをみんなで読んでみよう