<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Quill &#8211; エンジニア見習い</title>
	<atom:link href="https://otonan-syusyoku.work/archives/tag/quill/feed" rel="self" type="application/rss+xml" />
	<link>https://otonan-syusyoku.work</link>
	<description>三流プログラマー</description>
	<lastBuildDate>Sat, 06 Jan 2024 03:11:56 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://otonan-syusyoku.work/wp-content/uploads/2023/10/cropped-名称未設定のデザイン-16-32x32.png</url>
	<title>Quill &#8211; エンジニア見習い</title>
	<link>https://otonan-syusyoku.work</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>【Tips】Laravel+React-Quillで独自スタイルを適用する方法</title>
		<link>https://otonan-syusyoku.work/archives/1575</link>
					<comments>https://otonan-syusyoku.work/archives/1575#respond</comments>
		
		<dc:creator><![CDATA[hrokig2]]></dc:creator>
		<pubDate>Fri, 05 Jan 2024 11:53:19 +0000</pubDate>
				<category><![CDATA[好きではないJS]]></category>
		<category><![CDATA[Quill]]></category>
		<category><![CDATA[React]]></category>
		<category><![CDATA[コンポーネント]]></category>
		<guid isPermaLink="false">https://otonan-syusyoku.work/?p=1575</guid>

					<description><![CDATA[React-Quill を使用している際にスタイルを少しだけ変更したいといった場面があると思います〜 スタイルを当てる事に焦点を置いているので、UIのダサさは気にしないでください。 そんなときのちょっとしたTipsを紹介 [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>React-Quill を使用している際にスタイルを少しだけ変更したいといった場面があると思います〜</p>
<p>スタイルを当てる事に焦点を置いているので、UIのダサさは気にしないでください。</p>
<p>そんなときのちょっとしたTipsを紹介します。</p>
<h2>完成形</h2>
<h3>変更前</h3>
<p><img fetchpriority="high" decoding="async" src="https://otonan-syusyoku.work/wp-content/uploads/2024/01/スクリーンショット-2024-01-05-20.47.01.png" alt="Quill 変更前" width="878" height="166" class="aligncenter size-full wp-image-1578" srcset="https://otonan-syusyoku.work/wp-content/uploads/2024/01/スクリーンショット-2024-01-05-20.47.01.png 878w, https://otonan-syusyoku.work/wp-content/uploads/2024/01/スクリーンショット-2024-01-05-20.47.01-300x57.png 300w, https://otonan-syusyoku.work/wp-content/uploads/2024/01/スクリーンショット-2024-01-05-20.47.01-768x145.png 768w" sizes="(max-width: 878px) 100vw, 878px" /></p>
<h3>変更後</h3>
<p><img decoding="async" src="https://otonan-syusyoku.work/wp-content/uploads/2024/01/スクリーンショット-2024-01-05-20.46.19.png" alt="Quill 変更後" width="882" height="251" class="aligncenter size-full wp-image-1577" srcset="https://otonan-syusyoku.work/wp-content/uploads/2024/01/スクリーンショット-2024-01-05-20.46.19.png 882w, https://otonan-syusyoku.work/wp-content/uploads/2024/01/スクリーンショット-2024-01-05-20.46.19-300x85.png 300w, https://otonan-syusyoku.work/wp-content/uploads/2024/01/スクリーンショット-2024-01-05-20.46.19-768x219.png 768w" sizes="(max-width: 882px) 100vw, 882px" /></p>
<h2>なぜEditorに独自スタイルを当てるのか？</h2>
<p>ITリテラシーが低いユーザーに使用してもらうのが、一番の理由です。</p>
<p>殺風景なUIだとその時点でユーザーが離れてしまうことに最近気づきました。</p>
<p>プログラマーやエンジニアをやっている人には理解できないかもしれないのですが、リテラシーの低い人はとことん低いです。</p>
<ul>
<li>画面が味気ない</li>
<li>よくわからないボタン</li>
<li>英語</li>
</ul>
<p>少し考えたら分かるだろうと怒りたい気持ちもあるのですが、<span class="sc_marker blue"><strong>使ってもらえなければただのゴミを作ってしまうことになるので</strong></span>、工夫が必要です。</p>
<h2>CSSの定義</h2>
<p>Laravel の指定ディレクトリに Quill 用の CSS を用意します。</p>
<ul>
<li>`resources/css/Quill/style.css`</li>
<li>Quill 用にディレクトリを切って用意したほうが得策な気がします…</li>
</ul>
<pre class="line-numbers"><code class="language-css">.quill {
    .ql-toolbar {
        background-color: rgb(148 163 184); /* bg-slate-400 */
    }

    .ql-editor {
        h1, h2, h3 {
            padding-left: 0.5rem;
            border-radius: 0.5rem; /** rounded-lg */
            background-color: rgb(56 189 248); /* bg-sky-400 */
            color: white;
            margin-bottom: 1.2rem;
        }

        p {
            font-size: 1rem;
            margin-bottom: 1.2rem;
        }
    }
}</code></pre>
<p>&nbsp;</p>
<h2>定義したCSSをQuillコンポーネントで読み込み</h2>
<p>先ほど定義した CSS をQuill を定義しているコンポーネント内でインポートします。</p>
<ul>
<li>Quill のデフォルトのスタイルを上書きするために &#8216;react-quill/dist/quill.snow.css&#8217; の後にインポートするようにします</li>
</ul>
<pre class="line-numbers"><code class="language-php">import React from 'react';
import ReactQuill from 'react-quill';
import 'react-quill/dist/quill.snow.css';
import '@/../css/Quill/style.css';

export default function QuillEditor({ handleValueChange, value }) {
    const customToolbarOptions = [
        ['bold', 'italic', 'underline', 'strike'],        // toggled buttons
        ['link', 'image'],
        ['blockquote', 'code-block'],

        [{ 'header': 1 }, { 'header': 2 }],               // custom button values
        [{ 'list': 'ordered' }, { 'list': 'bullet' }],
        [{ 'script': 'sub' }, { 'script': 'super' }],      // superscript/subscript
        [{ 'indent': '-1' }, { 'indent': '+1' }],          // outdent/indent
        [{ 'direction': 'rtl' }],                         // text direction

        [{ 'size': ['small', false, 'large', 'huge'] }],  // custom dropdown
        [{ 'header': [1, 2, 3, 4, 5, 6, false] }],

        [{ 'color': [] }, { 'background': [] }],          // dropdown with defaults from theme
        [{ 'font': [] }],
        [{ 'align': [] }],

        ['clean']    
    ];

    // 親コンポーネントから受け取った関数を使って、inputの値を渡す
    const handleContentValueChange = (content) =&gt; {
        handleValueChange(content);
    };

    return (
        &lt;ReactQuill
            theme="snow"
            value={value} // 親コンポーネントから受け取った値を設定
            onChange={handleContentValueChange}
            modules={{
                toolbar: customToolbarOptions,
            }}
        /&gt;
    );
}
</code></pre>
<p>&nbsp;</p>
<h2>ReactQuill素晴らしい</h2>
<p>ReactQuillをメンテナンスしてくれている方たちに感謝を伝えたいです。</p>
<p>すごくお世話になっています。ありがとう。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://otonan-syusyoku.work/archives/1575/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
