Skip to content

Commit 0bac867

Browse files
committed
AI Overviewブロックの送信ボタンをテーマCSSの上書きに強くする
一部テーマで送信ボタンが四角く巨大化し矢印が消える問題を修正。 ボタン等のスタイルは全て詳細度0の :where() で書かれていたため、 テーマのボタン向けルール(.wp-block-button__link や button 要素、 form button[type=submit] など)が width/height/min-height/padding/ border-radius を上書きし、円形40pxのボタンが巨大な四角形になっていた。 ボックス系・レイアウト系プロパティのみ .hamelp-ai-overview を前置きして 詳細度 0,2,0 にスコープ化し、テーマの典型的なボタンセレクタに勝つように した。min-height:0 と padding:0 でテーマ注入値を打ち消し、max-height:none でテーマの高さ上限も無効化。色・背景・transition・hover・focusの色などの 装飾系プロパティは従来どおり :where() のまま残し、テーマからのカスタマイズ 性を維持する。 対象: src/blocks/ai-overview/style.scss - .hamelp-ai-overview__button の position/box/flex/border-radius 等をスコープ化 - .hamelp-ai-overview__button-icon の幅高さ(20px)をスコープ化 - .hamelp-ai-overview__input-row の position/display をスコープ化 - .hamelp-ai-overview__input の padding/min-height/box-sizing/field-sizing/ resize/align-content をスコープ化
1 parent 19664f7 commit 0bac867

1 file changed

Lines changed: 42 additions & 16 deletions

File tree

src/blocks/ai-overview/style.scss

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@
5555
gap: 0.5rem;
5656
}
5757

58-
:where(.hamelp-ai-overview__input-row) {
58+
// Layout-critical, so scoped (0,2,0) for theme-override resistance: the absolute
59+
// send button depends on this positioning context, and a theme `.wp-block-*`/
60+
// element rule at 0,0,0 could otherwise drop it, un-inset the button.
61+
.hamelp-ai-overview .hamelp-ai-overview__input-row {
5962
// Positioning context for the send button, which is taken out of flow and
6063
// floated inside the field's bottom-right corner (ChatGPT-style inset). The
6164
// field's own border/background/radius stay driven by the textarea's theme
@@ -77,13 +80,6 @@
7780

7881
:where(.hamelp-ai-overview__input) {
7982
flex: 1;
80-
box-sizing: border-box;
81-
// Reserve room on the right so typed text never runs under the inset send
82-
// button (right = btn size + 1rem to clear the button plus a small gap). The
83-
// vertical padding is SYMMETRIC (top/bottom both 0.75rem) so that, combined
84-
// with align-content: center below, the single line centers cleanly in the
85-
// content box regardless of the button size or the theme's line-height.
86-
padding: 0.75rem calc(var(--hamelp-btn-size) + 1rem) 0.75rem 0.75rem;
8783
border: 1px solid var(--hamelp-border);
8884
border-radius: var(--hamelp-radius, 3px);
8985
background: var(--hamelp-surface);
@@ -93,13 +89,26 @@
9389
// content (field-sizing) up to a cap so long input stays fully visible.
9490
font-family: inherit;
9591
line-height: 1.5;
92+
max-height: 8lh;
93+
}
94+
95+
// Box/layout props the inset depends on, scoped (0,2,0) for theme-override
96+
// resistance: a theme's `textarea`/`.wp-block-*` rule at 0,0,0 must not collapse
97+
// the reserved button space, the inflated min-height, or the centered line.
98+
.hamelp-ai-overview .hamelp-ai-overview__input {
99+
box-sizing: border-box;
100+
// Reserve room on the right so typed text never runs under the inset send
101+
// button (right = btn size + 1rem to clear the button plus a small gap). The
102+
// vertical padding is SYMMETRIC (top/bottom both 0.75rem) so that, combined
103+
// with align-content: center below, the single line centers cleanly in the
104+
// content box regardless of the button size or the theme's line-height.
105+
padding: 0.75rem calc(var(--hamelp-btn-size) + 1rem) 0.75rem 0.75rem;
96106
field-sizing: content;
97107
// Minimum height sized so the inset send button clears equal ~8px gaps on
98108
// every side in the single-line state: button height + 2 × the button's
99109
// corner inset (0.5rem each). field-sizing still grows the field past this
100110
// as text wraps, at which point the top gap widens.
101111
min-height: calc(var(--hamelp-btn-size) + 1rem);
102-
max-height: 8lh;
103112
resize: none;
104113
// Vertically CENTER the single line of text within the inflated min-height.
105114
// With symmetric vertical padding above, centering is metric-robust: the line
@@ -135,33 +144,50 @@
135144
}
136145
}
137146

138-
:where(.hamelp-ai-overview__button) {
147+
// Structural/box/layout props scoped (0,2,0) for theme-override resistance.
148+
// Theme button rules (`.wp-block-button__link`, `form button[type=submit]`, bare
149+
// `button`) at 0,0,0–0,1,1 otherwise win and inflate the button into a big
150+
// rectangle (and can push the arrow out). min-height:0 + padding:0 NEUTRALIZE
151+
// theme-injected values; max-height:none guards against theme height caps.
152+
// Cosmetics (background/gradient, color, transition, :hover, focus color) stay
153+
// low-specificity in :where() below so themes can still re-skin them.
154+
.hamelp-ai-overview .hamelp-ai-overview__button {
139155
// Fixed-size circular icon button (ChatGPT-style), floated inside the field's
140156
// bottom-right corner. The constant bottom offset keeps it pinned to the
141157
// bottom as the textarea grows, instead of riding up with the content.
142158
position: absolute;
143159
right: 0.5rem;
144160
bottom: 0.5rem;
145161
display: flex;
162+
flex: none;
146163
align-items: center;
147164
justify-content: center;
165+
box-sizing: border-box;
148166
width: var(--hamelp-btn-size);
149167
height: var(--hamelp-btn-size);
168+
min-height: 0;
169+
max-height: none;
150170
padding: 0;
151-
border: 1px solid transparent;
152171
border-radius: 50%;
172+
line-height: 1;
173+
}
174+
175+
// Keep the icon size enforced at the same specificity so a theme `button svg`
176+
// rule can't resize the arrow or push it out of the circle.
177+
.hamelp-ai-overview .hamelp-ai-overview__button-icon {
178+
width: 20px;
179+
height: 20px;
180+
}
181+
182+
:where(.hamelp-ai-overview__button) {
183+
border: 1px solid transparent;
153184
background: var(--hamelp-button-bg, #1571da);
154185
background: linear-gradient(135deg, var(--hamelp-button-bg, #1571da), var(--hamelp-accent-hover));
155186
color: var(--hamelp-on-accent);
156187
cursor: pointer;
157188
transition: opacity 0.2s ease;
158189
}
159190

160-
:where(.hamelp-ai-overview__button-icon) {
161-
width: 20px;
162-
height: 20px;
163-
}
164-
165191
:where(.hamelp-ai-overview__button:hover) {
166192
opacity: 0.9;
167193
}

0 commit comments

Comments
 (0)