feat: add utility CSS classes and start replacing inline styles

- Added comprehensive utility CSS classes to both builtin and pico stylesheets
- Replaced copy button, close button, title container, and header right styling
- 208 total inline styles identified across codebase
- Started systematic replacement with reusable CSS classes
This commit is contained in:
Russell Ballestrini 2025-07-09 20:36:03 -04:00
parent a49c9973ae
commit be1b22e2f0
3 changed files with 282 additions and 44 deletions

View file

@ -95,31 +95,9 @@ function addCodeBlockCopyButtons(element) {
// Create copy button
const copyBtn = document.createElement("button");
copyBtn.className = "code-copy-btn";
copyBtn.className = "uncloseai-code-copy-btn";
copyBtn.textContent = "📋";
copyBtn.title = "Copy code";
copyBtn.style.cssText = `
position: absolute;
top: 8px;
right: 8px;
background: rgba(0, 0, 0, 0.7);
color: white;
border: none;
border-radius: 4px;
padding: 4px 8px;
cursor: pointer;
font-size: 12px;
opacity: 0.8;
transition: opacity 0.2s;
z-index: 10;
`;
copyBtn.onmouseenter = () => {
copyBtn.style.opacity = "1";
};
copyBtn.onmouseleave = () => {
copyBtn.style.opacity = "0.8";
};
copyBtn.onclick = async () => {
try {
@ -224,8 +202,7 @@ async function openUncloseaiEmbeddedModalNew() {
`;
const titleContainer = document.createElement("div");
titleContainer.style.cssText =
"flex: 1; display: flex; flex-direction: column; gap: 4px;";
titleContainer.className = "uncloseai-title-container";
const title = document.createElement("h2");
title.innerHTML =
@ -250,24 +227,7 @@ async function openUncloseaiEmbeddedModalNew() {
const closeBtn = document.createElement("button");
closeBtn.textContent = "✕";
closeBtn.style.cssText = `
background: rgba(255,255,255,0.2);
border: none;
color: white;
font-size: 20px;
width: 36px;
height: 36px;
border-radius: 50%;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: background 0.2s;
`;
closeBtn.onmouseover = () =>
(closeBtn.style.background = "rgba(255,255,255,0.3)");
closeBtn.onmouseout = () =>
(closeBtn.style.background = "rgba(255,255,255,0.2)");
closeBtn.className = "uncloseai-btn-close";
closeBtn.onclick = () => {
modal.close();
document.body.removeChild(modal);
@ -280,7 +240,7 @@ async function openUncloseaiEmbeddedModalNew() {
menuBtn.className = "uncloseai-modal-settings-btn";
const headerRight = document.createElement("div");
headerRight.style.cssText = "display: flex; gap: 8px; align-items: center;";
headerRight.className = "uncloseai-flex-row";
headerRight.appendChild(menuBtn);
headerRight.appendChild(closeBtn);

View file

@ -554,6 +554,145 @@ dialog#tts-modal {
transition: width 0.1s;
}
/* =================================================================== */
/* COMMON UTILITY CLASSES */
/* =================================================================== */
/* Container Classes */
.uncloseai-flex-container {
display: flex;
flex-direction: column;
gap: 12px;
}
.uncloseai-flex-row {
display: flex;
align-items: center;
gap: 8px;
}
.uncloseai-grid-actions {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
gap: 8px;
}
.uncloseai-panel {
background: #ffffff;
border: 1px solid #dee2e6;
border-radius: 8px;
padding: 16px;
}
/* Button Classes */
.uncloseai-btn-primary {
padding: 8px 16px;
background: #f8f9fa;
border: 1px solid #dee2e6;
border-radius: 20px;
cursor: pointer;
font-size: 14px;
color: #495057;
transition: all 0.2s;
white-space: nowrap;
}
.uncloseai-btn-primary:hover {
background: #e9ecef;
}
.uncloseai-btn-small {
padding: 4px 8px;
font-size: 12px;
border-radius: 4px;
cursor: pointer;
transition: all 0.2s;
border: 1px solid #dee2e6;
background: #f8f9fa;
color: #495057;
}
.uncloseai-btn-small:hover {
background: #e9ecef;
}
.uncloseai-btn-close {
width: 36px;
height: 36px;
border-radius: 50%;
background: rgba(255,255,255,0.2);
border: none;
color: white;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
font-size: 18px;
transition: background 0.2s;
}
.uncloseai-btn-close:hover {
background: rgba(255,255,255,0.3);
}
/* Form Element Classes */
.uncloseai-input {
width: 100%;
padding: 8px 12px;
border: 1px solid #dee2e6;
border-radius: 6px;
font-size: 14px;
background: #ffffff;
color: #495057;
}
.uncloseai-label {
display: block;
margin-bottom: 8px;
font-weight: 600;
color: #495057;
}
.uncloseai-section {
margin-bottom: 16px;
}
.uncloseai-title-container {
flex: 1;
display: flex;
flex-direction: column;
gap: 4px;
}
/* Code block styles */
.uncloseai-code-copy-btn {
position: absolute;
top: 8px;
right: 8px;
background: rgba(0, 0, 0, 0.7);
color: white;
border: none;
padding: 4px 8px;
border-radius: 4px;
font-size: 12px;
cursor: pointer;
opacity: 0.8;
transition: opacity 0.2s;
z-index: 10;
}
.uncloseai-code-copy-btn:hover {
opacity: 1;
}
/* Message action buttons */
.uncloseai-message-actions {
margin-top: 8px;
display: flex;
gap: 8px;
opacity: 0.7;
}
/* =================================================================== */
/* WIDGET LIBRARY STYLES */
/* =================================================================== */

View file

@ -605,6 +605,145 @@ dialog#tts-modal {
transition: width 0.1s;
}
/* =================================================================== */
/* COMMON UTILITY CLASSES - PICOCSS OVERRIDES */
/* =================================================================== */
/* Container Classes */
.uncloseai-flex-container {
display: flex;
flex-direction: column;
gap: 12px;
}
.uncloseai-flex-row {
display: flex;
align-items: center;
gap: 8px;
}
.uncloseai-grid-actions {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
gap: 8px;
}
.uncloseai-panel {
background: #ffffff;
border: 1px solid #dee2e6;
border-radius: 8px;
padding: 16px;
}
/* Button Classes */
.uncloseai-btn-primary {
padding: 8px 16px;
background: #f8f9fa;
border: 1px solid #dee2e6;
border-radius: 20px;
cursor: pointer;
font-size: 14px;
color: #495057;
transition: all 0.2s;
white-space: nowrap;
}
.uncloseai-btn-primary:hover {
background: #e9ecef;
}
.uncloseai-btn-small {
padding: 4px 8px;
font-size: 12px;
border-radius: 4px;
cursor: pointer;
transition: all 0.2s;
border: 1px solid #dee2e6;
background: #f8f9fa;
color: #495057;
}
.uncloseai-btn-small:hover {
background: #e9ecef;
}
.uncloseai-btn-close {
width: 36px;
height: 36px;
border-radius: 50%;
background: rgba(255,255,255,0.2);
border: none;
color: white;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
font-size: 18px;
transition: background 0.2s;
}
.uncloseai-btn-close:hover {
background: rgba(255,255,255,0.3);
}
/* Form Element Classes */
.uncloseai-input {
width: 100%;
padding: 8px 12px;
border: 1px solid #dee2e6;
border-radius: 6px;
font-size: 14px;
background: #ffffff;
color: #495057;
}
.uncloseai-label {
display: block;
margin-bottom: 8px;
font-weight: 600;
color: #495057;
}
.uncloseai-section {
margin-bottom: 16px;
}
.uncloseai-title-container {
flex: 1;
display: flex;
flex-direction: column;
gap: 4px;
}
/* Code block styles */
.uncloseai-code-copy-btn {
position: absolute;
top: 8px;
right: 8px;
background: rgba(0, 0, 0, 0.7);
color: white;
border: none;
padding: 4px 8px;
border-radius: 4px;
font-size: 12px;
cursor: pointer;
opacity: 0.8;
transition: opacity 0.2s;
z-index: 10;
}
.uncloseai-code-copy-btn:hover {
opacity: 1;
}
/* Message action buttons */
.uncloseai-message-actions {
margin-top: 8px;
display: flex;
gap: 8px;
opacity: 0.7;
}
/* =================================================================== */
/* WIDGET LIBRARY STYLES - PICOCSS OVERRIDES */
/* =================================================================== */