remove redundant styles from this code and debug it. top… · The Chat Archive
Explore / Programming o1-preview-2024-09-12 · OpenAI WildChat-4.8M (AI2)remove redundant styles from this code and debug it. top header should be blur effect in… Save Share Download ▾ Reportremove redundant styles from this code and debug it. top header should be blur effect in light and dark modes, and all buttons must have similar glow effect to what the send message button has (even those on top header) fix overall look and feel so it looks much more closer to the apple.com website
[data-theme="dark"] {
--primary: #0A84FF; /* Brighter blue for dark mode /
--secondary: #30D158; / Brighter green for dark mode /
--background-light: #1C1C1E;
--background-dark: #000000;
--text-light: #FFFFFF;
--text-dark: #FFFFFF;
--grey-light: #3A3A3C;
--grey-dark: #2C2C2E;
--header-border: #3A3A3C; / Header border color in dark mode */
--header-background-dark: rgba(29,29,31,0.8);
}
{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', sans-serif;
-webkit-font-smoothing: antialiased;
line-height: 1.5;
height: 100vh;
overflow: hidden;
background: var(--background-light);
transition: all var(--transition-time) ease;
}
.header {
background: var(--header-background);
color: var(--text-light);
padding: 0.5rem 3rem; /* Reduced padding /
display: flex;
justify-content: space-between;
align-items: center;
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
font-size: 0.8rem; / Reduced from 0.9rem for a slimmer header /
height: 48px; / Set a fixed thinner height /
border-bottom: 1px solid var(--header-border); / Update border to use the new variable */
}
.header h1 {
font-size: 14px;
font-weight: 550;
padding-left: 4rem;
}
.container {
height: calc(100vh - 58px); /* Reduced by 20px for bottom margin /
margin-bottom: 20px; / Added bottom margin /
padding: 5px 5px 5px 5px; / Keep existing padding /
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-rows: auto 1fr;
gap: 5px; / Add gap between sections /
background: white; / Add background to container to show card separation */
transition: all var(--transition-time) ease;
}
.code-panel {
grid-column: 1;
grid-row: 1;
height: 50vh;
border: none; /* Removed border */
padding: 5px;
background: var(--background-light);
}
.chatbot-container {
grid-column: 1;
grid-row: 2;
position: relative; /* Add relative positioning /
flex-direction: column; / Stack children vertically /
background: var(--background-light); / Update chatbot container background /
border: none; / Removed border */
padding: 5px;
}
.preview-panel {
grid-column: 2;
grid-row: 1 / span 2;
border: none; /* Removed border */
padding: 5px;
background: var(--background-light);
}
.vertical-separator {
width: 1px;
height: 100%;
background: var(--header-border); /* Match separator color with header border */
transition: transform var(--transition-time), opacity var(--transition-time);
transform: translateX(0);
opacity: 1;
}
Assistant2024-11-17 06:07 UTC Copy response
Copy first prompt
Other models, same or similar prompt Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Details
Model o1-preview-2024-09-12
Provider OpenAI
Model provenance As recorded by source dataset
Turns 1 (2 messages)
Language en
Conversation date Nov 17, 2024
Added to archive Nov 17, 2026
ID 01m7h4294g7dhtarm1bz1x2swwSource & license Imported from WildChat-4.8M (AI2) (source ). Imported records earn no Research Points.
Upstream record: ce2f600d9c0c6fd546c387438aad7c57
Zhao et al., WildChat: 1M ChatGPT Interaction Logs in the Wild (ICLR 2024). Contains information from WildChat-4.8M, made available under the ODC Attribution License.
License: ODC-BY-1.0
Dataset releases Not yet included in a published release.
[data-theme="dark"] .vertical-separator {
background: var(--header-border);
}
.resize-handle {
width: 6px;
cursor: col-resize;
background: var(--grey-light);
border-radius: 3px;
transition: background var(--transition-time);
}
.container:hover .resize-handle {
background: var(--primary);
}
.code-editor {
width: 100%;
height: calc(100% - 40px);
background: var(--background-light);
color: var(--text-light);
border: none;
font-family: 'SF Mono', 'Courier New', monospace;
font-size: 14px;
padding: 1rem;
border-radius: 0; /* Removed border-radius /
box-shadow: none; / Removed box-shadow /
transition: background var(--transition-time), color var(--transition-time);
resize: none; / Disable resizing on the code editor textarea */
}
[data-theme="dark"] .code-editor {
background: var(--background-dark);
color: var(--text-dark);
}
.toggle-buttons {
position: fixed;
}
.toggle-buttons button {
width: 24px;
height: 24px;
padding: 6px;
background: var(--grey-light);
color: var(--text-light);
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: all var(--transition-time) ease;
}
[data-theme="dark"] .toggle-buttons button {
background: var(--grey-dark);
color: var(--text-dark);
}
.toggle-buttons button:hover {
background: var(--secondary);
transform: translateY(-1px);
}
.toggle-buttons button:active {
transform: translateY(0);
}
.button-group {
display: flex;
gap: 0.5rem;
align-items: center;
}
.button-group button {
width: 32px; /* Reduced width from 40px to 32px /
height: 32px; / Reduced height from 40px to 32px /
padding: 6px; / Adjusted padding for smaller buttons /
border-radius: 16px; / Reduced border-radius for smaller buttons */
background: var(--grey-light);
}
[data-theme="dark"] .button-group button {
background: var(--grey-dark);
}
.code-panel-buttons {
/* Removed to place toggle buttons separately */
margin-bottom: 0.5rem;
position: relative;
}
button {
padding: 6px 12px; /* Reduced padding /
border-radius: 6px; / Reduced border-radius /
font-size: 12px; / Reduced font size */
font-weight: 600;
background: var(--primary);
border: none;
cursor: pointer;
transition: all var(--transition-time) ease;
color: var(--text-dark);
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
button:hover {
background: var(--secondary);
transform: translateY(-1px);
}
button:hover svg {
stroke: var(--text-dark);
}
button:active {
transform: translateY(0);
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}
.theme-toggle,
.hamburger-btn,
.copy-btn {
width: 32px;
height: 32px;
padding: 6px;
border-radius: 16px;
background: var(--grey-light);
color: var(--text-light);
border: none;
box-shadow: none;
transition: all var(--transition-time) ease;
display: flex;
align-items: center;
justify-content: center;
}
.chatbot-input {
position: sticky; /* Keep input fixed at bottom */
bottom: 0;
padding-top: 1em;
display: flex;
gap: 8px;
border-top: 1px solid var(--header-border);
background: var(--background-light);
}
[data-theme="dark"] .chatbot-input {
background: var(--background-dark);
}
.chatbot-header {
font-size: 12px;
}
.chatbot-input input[type="text"] {
color: var(--text-light);
font-size: 14px;
}
[data-theme="dark"] .chatbot-input input[type="text"] {
background: var(--grey-dark);
color: var(--text-dark);
}
.chatbot-input button {
display: flex;
align-items: center;
justify-content: center;
background: var(--primary);
color: #FFFFFF; /* Always white for better contrast on blue /
font-weight: 500; / Apple uses slightly less bold fonts */
transition: all var(--transition-time) ease;
}
.input-group {
display: flex;
gap: 8px;
width: 100%;
align-items: center;
justify-content: center;
}
.message {
padding: 10px 14px;
font-size: 14px;
border-radius: 20px;
max-width: 80%;
line-height: 1.5;
margin-bottom: 8px; /* Remove any grey backgrounds from messages container /
width: fit-content; / Add this to make bubbles fit content */
}
.user-message {
background: var(--primary);
color: var(--text-dark);
align-self: flex-end;
border-top-right-radius: 0;
margin-left: auto; /* Add this to align right */
}
.bot-message {
background: var(--grey-light);
color: var(--text-light);
align-self: flex-start;
border-top-left-radius: 0;
margin-right: auto; /* Add this to align left */
}
[data-theme="dark"] .bot-message {
background: var(--grey-dark);
color: var(--text-dark);
}
/* Tooltip container */
.tooltip {
position: relative;
display: inline-block;
}
/* Tooltip text /
.tooltip .tooltip-text {
visibility: hidden;
width: max-content;
background-color: rgba(0, 0, 0, 0.75);
color: #fff;
text-align: center;
border-radius: 6px;
padding: 4px 8px;
position: absolute;
z-index: 1002;
bottom: 125%; / Position above the element /
left: 50%;
transform: translateX(-50%);
max-width: 200px; / Ensure tooltip doesn't go beyond viewport */
opacity: 0;
transition: opacity var(--transition-time) ease;
font-size: 12px;
white-space: nowrap;
}
/* Tooltip arrow /
.tooltip .tooltip-text::after {
content: "";
position: absolute;
top: 100%; / At the bottom of the tooltip */
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: rgba(0, 0, 0, 0.75) transparent transparent transparent;
}
/* Show the tooltip on hover */
.tooltip:hover .tooltip-text {
visibility: visible;
opacity: 1;
}
/* Define the collapsed state */
.container.collapsed {
grid-template-columns: 0 1fr;
transition: all var(--transition-time) ease;
}
.container.collapsed .code-panel,
.container.collapsed .chatbot-container {
display: none;
}
.container.collapsed .preview-panel {
grid-column: 1 / span 2;
}
/* Ensure messages stay within bounds /
.chatbot-messages {
overflow-y: auto;
height: calc(100% - 70px); / Account for input area height */
padding: 10px;
}
[data-theme="dark"] .chatbot-input {
background: var(--background-dark);
}
.chatbot-container {
display: flex;
flex-direction: column;
}
.chatbot-window {
display: flex;
flex-direction: column;
height: 100%;
}
.chatbot-messages {
flex-grow: 1;
overflow-y: auto;
padding-bottom: 10px;
}
.chat-input-container {
display: flex;
align-items: center;
gap: 12px;
width: fit-content;
}
.input-wrapper {
position: relative;
}
.input-wrapper input {
background-color: rgb(255, 255, 255);
border: 1px solid var(--color-border-grey);
border-radius: 12px;
box-sizing: border-box;
color: var(--color-text);
font-family: "SF Pro Text", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 17px;
height: 38px;
width: 600px;
padding: 6px 16px;
line-height: 25px;
letter-spacing: -0.374px;
transition: border-color 0.2s ease, box-shadow 0.2s ease;
-webkit-font-smoothing: antialiased;
}
.input-wrapper input::placeholder {
color: var(--color-border-grey);
}
.input-wrapper input:focus {
outline: none;
border-color: var(--color-fill-blue);
box-shadow: var(--color-focus-color) 0px 0px 0px 4px;
}
.input-wrapper input:focus::placeholder {
color: transparent;
}
.send-button {
background-color: black;
border: 1px solid transparent;
border-radius: 12px;
color: white;
cursor: pointer;
height: 38px;
width: 38px;
padding: 8px;
transition: all 0.2s ease;
display: flex;
align-items: center;
justify-content: center;
position: relative;
overflow: hidden;
}
.send-button:hover {
background-color: var(--color-fill-blue);
border-color: var(--color-fill-blue);
box-shadow: var(--color-focus-color) 0px 0px 0px 4px;
}
.send-button.clicked {
background-color: var(--color-success);
border-color: var(--color-success);
box-shadow: var(--color-success-glow) 0px 0px 0px 4px;
}
.icon-container {
width: 16px;
height: 16px;
position: relative;
display: flex;
align-items: center;
justify-content: center;
}
.send-button svg {
width: 16px;
height: 16px;
position: absolute;
}
@keyframes flyAway {
0% {
transform: translate(-20px, 20px) rotate(45deg);
opacity: 1;
}
100% {
transform: translate(20px, -20px) rotate(-45deg);
opacity: 0;
}
}
@keyframes flyBack {
0% {
transform: translate(-20px, 20px) rotate(45deg);
fill: currentColor;
}
100% {
transform: translate(0, 0) rotate(0);
fill: transparent;
}
}
.send-button .icon-outline {
stroke: currentColor;
fill: transparent;
}
.send-button.clicked .icon-outline {
fill: currentColor;
animation: flyAway 0.6s ease-out forwards;
}
.send-button.returning .icon-outline {
animation: flyBack 0.6s ease-out forwards;
}
});
messageDiv.innerHTML = formattedContent;
} else {
messageDiv.textContent = content;
}
messagesContainer.appendChild(messageDiv);
messagesContainer.scrollTop = messagesContainer.scrollHeight;
}
Here is the updated code with redundant styles removed and the requested improvements. The top header now has a blur effect in both light and dark modes, and all buttons have a glow effect similar to the send message button. The overall look and feel has been adjusted to more closely resemble the Apple.com website.
<!DOCTYPE html>
<html>
<head>
<title>WebSim Code Editor</title>
<style>
:root {
--primary: #007AFF; /* Apple iOS blue */
--secondary: #000000; /* Black */
--background-light: #F5F5F7;
--background-dark: #1C1C1E;
--text-light: #000000;
--text-dark: #FFFFFF;
--grey-light: #E5E5EA;
--grey-dark: #3A3A3C;
--transition-time: 0.3s;
--header-border: #D3D3D3;
--header-background: rgba(250, 250, 252, 0.8);
--header-backdrop-filter: saturate(180%) blur(20px);
--button-background: #000000;
--button-hover-background: var(--primary);
--button-hover-box-shadow: rgba(0, 125, 250, 0.6) 0px 0px 0px 4px;
}
[data-theme="dark"] {
--primary: #0A84FF;
--secondary: #30D158;
--background-light: #1C1C1E;
--background-dark: #000000;
--text-light: #FFFFFF;
--text-dark: #FFFFFF;
--grey-light: #3A3A3C;
--grey-dark: #2C2C2E;
--header-border: #3A3A3C;
--header-background: rgba(29, 29, 31, 0.8);
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', sans-serif;
-webkit-font-smoothing: antialiased;
line-height: 1.5;
height: 100vh;
overflow: hidden;
background: var(--background-light);
transition: background var(--transition-time) ease;
}
[data-theme="dark"] body {
background: var(--background-dark);
}
.header {
background: var(--header-background);
backdrop-filter: var(--header-backdrop-filter);
color: var(--text-light);
padding: 0.5rem 3rem;
display: flex;
justify-content: space-between;
align-items: center;
height: 48px;
border-bottom: 1px solid var(--header-border);
}
[data-theme="dark"] .header {
color: var(--text-dark);
}
.header h1 {
font-size: 14px;
font-weight: 550;
padding-left: 4rem;
}
.container {
height: calc(100vh - 48px);
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-rows: auto 1fr;
gap: 5px;
transition: all var(--transition-time) ease;
}
.code-panel, .chatbot-container, .preview-panel {
padding: 5px;
background: var(--background-light);
}
[data-theme="dark"] .code-panel,
[data-theme="dark"] .chatbot-container,
[data-theme="dark"] .preview-panel {
background: var(--background-dark);
}
.code-panel {
grid-column: 1;
grid-row: 1 / 2;
height: 50vh;
}
.chatbot-container {
grid-column: 1;
grid-row: 2 / 3;
display: flex;
flex-direction: column;
position: relative;
}
.preview-panel {
grid-column: 2;
grid-row: 1 / 3;
}
.code-editor {
width: 100%;
height: calc(100% - 40px);
background: var(--background-light);
color: var(--text-light);
border: none;
font-family: 'SF Mono', 'Courier New', monospace;
font-size: 14px;
padding: 1rem;
transition: background var(--transition-time), color var(--transition-time);
resize: none;
}
[data-theme="dark"] .code-editor {
background: var(--background-dark);
color: var(--text-dark);
}
.button {
background-color: var(--button-background);
border: 1px solid transparent;
border-radius: 12px;
color: var(--text-dark);
cursor: pointer;
height: 38px;
padding: 8px 16px;
transition: all 0.2s ease;
display: flex;
align-items: center;
justify-content: center;
}
.button:hover {
background-color: var(--button-hover-background);
box-shadow: var(--button-hover-box-shadow);
border-color: var(--primary);
}
.toggle-buttons {
display: flex;
gap: 12px;
}
.toggle-buttons .button {
width: 38px;
padding: 0;
}
.chatbot-input {
position: sticky;
bottom: 0;
padding-top: 1em;
display: flex;
gap: 8px;
border-top: 1px solid var(--header-border);
background: var(--background-light);
}
[data-theme="dark"] .chatbot-input {
background: var(--background-dark);
}
.chatbot-messages {
overflow-y: auto;
height: calc(100% - 70px);
padding: 10px;
}
.message {
padding: 10px 14px;
font-size: 14px;
border-radius: 20px;
max-width: 80%;
line-height: 1.5;
margin-bottom: 8px;
width: fit-content;
}
.user-message {
background: var(--primary);
color: var(--text-dark);
align-self: flex-end;
border-top-right-radius: 0;
}
.bot-message {
background: var(--grey-light);
color: var(--text-light);
align-self: flex-start;
border-top-left-radius: 0;
}
[data-theme="dark"] .bot-message {
background: var(--grey-dark);
color: var(--text-dark);
}
.tooltip {
position: relative;
display: inline-block;
}
.tooltip .tooltip-text {
visibility: hidden;
background-color: rgba(0, 0, 0, 0.75);
color: #fff;
text-align: center;
border-radius: 6px;
padding: 4px 8px;
position: absolute;
z-index: 1002;
bottom: 125%;
left: 50%;
transform: translateX(-50%);
opacity: 0;
transition: opacity var(--transition-time) ease;
font-size: 12px;
white-space: nowrap;
}
.tooltip .tooltip-text::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: rgba(0, 0, 0, 0.75) transparent transparent transparent;
}
.tooltip:hover .tooltip-text {
visibility: visible;
opacity: 1;
}
.container.collapsed {
grid-template-columns: 0 1fr;
}
.container.collapsed .code-panel,
.container.collapsed .chatbot-container {
display: none;
}
.container.collapsed .preview-panel {
grid-column: 1 / -1;
}
/* Input and Send Button Styles */
.chat-input-container {
display: flex;
align-items: center;
gap: 12px;
width: 100%;
}
.input-wrapper {
flex-grow: 1;
}
.input-wrapper input {
background-color: var(--background-light);
border: 1px solid var(--grey-light);
border-radius: 12px;
color: var(--text-light);
font-size: 17px;
height: 38px;
padding: 6px 16px;
transition: border-color 0.2s ease, box-shadow 0.2s ease;
width: 100%;
}
[data-theme="dark"] .input-wrapper input {
background-color: var(--grey-dark);
border-color: var(--grey-dark);
color: var(--text-dark);
}
.input-wrapper input:focus {
outline: none;
border-color: var(--primary);
box-shadow: rgba(0, 125, 250, 0.6) 0px 0px 0px 4px;
}
.send-button {
background-color: var(--button-background);
border: 1px solid transparent;
border-radius: 12px;
color: var(--text-dark);
cursor: pointer;
height: 38px;
width: 38px;
padding: 8px;
transition: all 0.2s ease;
display: flex;
align-items: center;
justify-content: center;
position: relative;
overflow: hidden;
}
.send-button:hover {
background-color: var(--button-hover-background);
box-shadow: var(--button-hover-box-shadow);
border-color: var(--primary);
}
/* Icon Styles */
.icon-container {
width: 16px;
height: 16px;
position: relative;
display: flex;
align-items: center;
justify-content: center;
}
.send-button svg {
width: 16px;
height: 16px;
position: absolute;
}
/* Fly Away Animation */
@keyframes flyAway {
0% {
transform: translate(-20px, 20px) rotate(45deg);
opacity: 1;
}
100% {
transform: translate(20px, -20px) rotate(-45deg);
opacity: 0;
}
}
@keyframes flyBack {
0% {
transform: translate(-20px, 20px) rotate(45deg);
fill: currentColor;
}
100% {
transform: translate(0, 0) rotate(0);
fill: transparent;
}
}
.send-button .icon-outline {
stroke: currentColor;
fill: transparent;
}
.send-button.clicked .icon-outline {
fill: currentColor;
animation: flyAway 0.6s ease-out forwards;
}
.send-button.returning .icon-outline {
animation: flyBack 0.6s ease-out forwards;
}
</style>
</head>
<body>
<div class="header">
<div class="toggle-buttons">
<div class="tooltip">
<button class="button" onclick="toggleCodePanel()" aria-label="Toggle Code Panel">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="3" y1="12" x2="21" y2="12"></line>
<line x1="3" y1="6" x2="21" y2="6"></line>
<line x1="3" y1="18" x2="21" y2="18"></line>
</svg>
<span class="tooltip-text">Collapse Code Panel</span>
</button>
</div>
<div class="tooltip">
<button class="button" onclick="copyCode()" aria-label="Copy Code">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M16 1H4a2 2 0 0 0-2 2v14h2V3h12V1z"></path>
<path d="M8 5H20a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2z"></path>
</svg>
<span class="tooltip-text">Copy Code</span>
</button>
</div>
</div>
<h1>WebSim Code Editor</h1>
<div class="button-group">
<div class="tooltip">
<button onclick="toggleTheme()" class="button" id="themeToggle" aria-label="Toggle Theme">
<svg class="moon-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path>
</svg>
<span class="tooltip-text">Toggle Theme</span>
</button>
</div>
</div>
</div>
<div class="container">
<div class="code-panel">
<textarea class="code-editor" id="codeEditor" spellcheck="false" oninput="updatePreview()"></textarea>
</div>
<div class="chatbot-container">
<div class="chatbot-window">
<div class="chatbot-header">WebSim Coding Assistant</div>
<div class="chatbot-messages" id="chatbotMessages"></div>
<div class="chatbot-input">
<div class="chat-input-container">
<div class="input-wrapper">
<input type="text" id="chatbotInput" placeholder="Create or enhance code...">
</div>
<button class="send-button" onclick="sendMessage()" aria-label="Send message">
<div class="icon-container">
<svg class="icon-outline" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<line x1="22" y1="2" x2="11" y2="13"></line>
<path d="M22 2L2 9l9 4l4 9l7-20z"></path>
</svg>
</div>
</button>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const button = document.querySelector('.send-button');
const input = document.querySelector('#chatbotInput');
function triggerSendAnimation() {
if (!button.classList.contains('clicked')) {
button.classList.add('clicked');
setTimeout(() => {
button.classList.remove('clicked');
button.classList.add('returning');
setTimeout(() => {
button.classList.remove('returning');
}, 600);
}, 600);
}
}
button.addEventListener('click', triggerSendAnimation);
input.addEventListener('keypress', function(event) {
if (event.key === 'Enter') {
event.preventDefault();
triggerSendAnimation();
sendMessage();
}
});
});
</script>
</div>
</div>
</div>
<div class="preview-panel" id="previewPanel">
<iframe id="preview" style="width: 100%; height: 100%; border: none;"></iframe>
</div>
</div>
<script>
let currentImage = null;
let chatHistory = [];
function sendMessage() {
const input = document.getElementById('chatbotInput');
const message = input.value.trim();
if (!message) return;
addMessage(message, true);
input.value = '';
// Simulating an AI response for demonstration purposes
const botResponse = "Here's some code for you: ```<p>Hello World!</p>```";
if (botResponse.includes('```')) {
const codeMatch = botResponse.match(/```(?:\w+\n)?([\s\S]*?)```/);
if (codeMatch && codeMatch[1]) {
const code = codeMatch[1].trim();
document.getElementById('codeEditor').value = code;
updatePreview();
}
const messageWithoutCode = botResponse.replace(/```[\s\S]*?```/g, '[Code has been added to editor]');
addMessage(messageWithoutCode);
} else {
addMessage(botResponse);
}
chatHistory.push({ role: 'user', content: message });
chatHistory.push({ role: 'assistant', content: botResponse });
}
function toggleTheme() {
const body = document.body;
const themeToggle = document.getElementById('themeToggle');
const isDark = body.getAttribute('data-theme') === 'dark';
if (isDark) {
body.removeAttribute('data-theme');
themeToggle.innerHTML = `
<svg class="moon-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path>
</svg>
`;
} else {
body.setAttribute('data-theme', 'dark');
themeToggle.innerHTML = `
<svg class="sun-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="5"></circle>
<line x1="12" y1="1" x2="12" y2="3"></line>
<line x1="12" y1="21" x2="12" y2="23"></line>
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
<line x1="1" y1="12" x2="3" y2="12"></line>
<line x1="21" y1="12" x2="23" y2="12"></line>
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
</svg>
`;
}
updatePreview();
}
function toggleCodePanel() {
const container = document.querySelector('.container');
container.classList.toggle('collapsed');
}
function copyCode() {
const codeEditor = document.getElementById('codeEditor');
codeEditor.select();
document.execCommand('copy');
}
function updatePreview() {
const codeEditor = document.getElementById('codeEditor');
const preview = document.getElementById('preview');
const code = codeEditor.value;
const previewDocument = preview.contentDocument || preview.contentWindow.document;
previewDocument.open();
const isDarkMode = document.body.getAttribute('data-theme') === 'dark';
const themeClass = isDarkMode ? 'data-theme="dark"' : '';
previewDocument.write(`<body ${themeClass}>${code}</body>`);
previewDocument.close();
}
document.addEventListener('DOMContentLoaded', () => {
const preview = document.getElementById('preview');
const previewDocument = preview.contentDocument || preview.contentWindow.document;
previewDocument.open();
previewDocument.write('<!-- Enter your code in the editor to see preview -->');
previewDocument.close();
});
function addMessage(content, isUser = false) {
const messagesContainer = document.getElementById('chatbotMessages');
const messageDiv = document.createElement('div');
messageDiv.classList.add('message');
messageDiv.classList.add(isUser ? 'user-message' : 'bot-message');
if (content.includes('```')) {
const formattedContent = content.replace(/```([\s\S]*?)```/g, (match, code) => {
return `<pre><code>${code.trim()}</code></pre>`;
});
messageDiv.innerHTML = formattedContent;
} else {
messageDiv.textContent = content;
}
messagesContainer.appendChild(messageDiv);
messagesContainer.scrollTop = messagesContainer.scrollHeight;
}
</script>
</body>
</html>
Notes:
Header Blur Effect: The header now uses backdrop-filter with a blur effect, and the background color adjusts based on light or dark mode.
Button Glow Effect: All buttons now share a common .button class that applies the glow effect similar to the send message button.
Redundant Styles Removed: Unused CSS classes and redundant styles have been removed for cleaner code.
Apple.com Look and Feel: Fonts, colors, and overall styling have been adjusted to more closely match the minimalist and clean aesthetic of Apple’s website.
Let me know if you need any further adjustments!
Copy first response