botserver/docs/src/chapter-05-gbtheme/README.md

206 lines
4.9 KiB
Markdown
Raw Normal View History

2025-11-23 20:12:09 -03:00
# Chapter 05: gbtheme CSS Theming
2025-11-23 09:19:06 -03:00
2025-11-23 20:12:09 -03:00
The `.gbtheme` package provides CSS-based styling for your bot's user interface. Themes control colors, fonts, layouts, and visual effects across all .gbui templates.
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
## Quick Start
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
1. Create a `.gbtheme` folder in your bot package
2. Add a CSS file (like `default.css` or `3dbevel.css`)
3. The theme loads automatically when the bot starts
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
## Theme Structure
2025-11-23 09:19:06 -03:00
```
2025-11-23 13:46:55 -03:00
mybot.gbai/
└── mybot.gbtheme/
├── default.css # Main theme
├── 3dbevel.css # Retro Windows 95 style
└── dark.css # Dark mode variant
2025-11-23 09:19:06 -03:00
```
2025-11-23 13:46:55 -03:00
## The 3D Bevel Theme
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
The `3dbevel.css` theme gives your bot a classic Windows 95 look with 3D beveled edges:
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
```css
/* Everything uses monospace font for that retro feel */
body, .card, .popover, .input, .button, .menu, .dialog {
font-family: 'IBM Plex Mono', 'Courier New', monospace !important;
background: #c0c0c0 !important;
color: #000 !important;
border-radius: 0 !important; /* No rounded corners */
box-shadow: none !important;
}
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
/* 3D bevel effect on panels */
.card, .popover, .menu, .dialog {
border: 2px solid #fff !important; /* Top/left highlight */
border-bottom: 2px solid #404040 !important; /* Bottom shadow */
border-right: 2px solid #404040 !important; /* Right shadow */
padding: 8px !important;
background: #e0e0e0 !important;
}
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
/* Buttons with 3D effect */
.button, button, input[type="button"], input[type="submit"] {
background: #e0e0e0 !important;
color: #000 !important;
border: 2px solid #fff !important;
border-bottom: 2px solid #404040 !important;
border-right: 2px solid #404040 !important;
padding: 4px 12px !important;
font-weight: bold !important;
}
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
/* Input fields look recessed */
input, textarea, select {
background: #fff !important;
color: #000 !important;
border: 2px solid #404040 !important; /* Reversed for inset look */
border-bottom: 2px solid #fff !important;
border-right: 2px solid #fff !important;
}
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
/* Classic scrollbars */
::-webkit-scrollbar {
width: 16px !important;
background: #c0c0c0 !important;
}
::-webkit-scrollbar-thumb {
background: #404040 !important;
border: 2px solid #fff !important;
border-bottom: 2px solid #404040 !important;
border-right: 2px solid #404040 !important;
}
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
/* Blue hyperlinks like Windows 95 */
a {
color: #0000aa !important;
text-decoration: underline !important;
2025-11-23 09:19:06 -03:00
}
```
2025-11-23 13:46:55 -03:00
## How Themes Work
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
1. **CSS Variables**: Themes use CSS custom properties for colors
2. **Class Targeting**: Style specific bot UI elements
3. **Important Rules**: Override default styles with `!important`
4. **Font Stacks**: Provide fallback fonts for compatibility
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
## Creating Your Own Theme
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
Start with this template:
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
```css
/* Basic color scheme */
:root {
--primary: #007bff;
--background: #ffffff;
--text: #333333;
--border: #dee2e6;
}
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
/* Chat container */
.chat-container {
background: var(--background);
color: var(--text);
}
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
/* Messages */
.message-user {
background: var(--primary);
color: white;
}
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
.message-bot {
background: var(--border);
color: var(--text);
}
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
/* Input area */
.chat-input {
border: 1px solid var(--border);
background: var(--background);
}
2025-11-23 09:19:06 -03:00
```
2025-11-23 13:46:55 -03:00
## Switching Themes
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
Use the `CHANGE THEME` keyword in your BASIC scripts:
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
```basic
' Switch to retro theme
CHANGE THEME "3dbevel"
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
' Back to default
CHANGE THEME "default"
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
' Seasonal themes
month = MONTH(NOW())
IF month = 12 THEN
CHANGE THEME "holiday"
END IF
```
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
## Common Theme Elements
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
### Message Bubbles
```css
.message {
padding: 10px;
margin: 5px;
border-radius: 10px;
}
```
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
### Suggestion Buttons
```css
.suggestion-button {
background: #f0f0f0;
border: 1px solid #ccc;
padding: 8px 16px;
margin: 4px;
cursor: pointer;
}
```
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
### Input Field
```css
.chat-input {
width: 100%;
padding: 10px;
font-size: 16px;
}
```
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
## Theme Best Practices
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
1. **Test on Multiple Browsers**: Ensure compatibility
2. **Use Web-Safe Fonts**: Or include font files
3. **High Contrast**: Ensure readability
4. **Mobile Responsive**: Test on different screen sizes
5. **Keep It Simple**: Don't overcomplicate the CSS
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
## File Naming
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
- `default.css` - Loaded automatically as main theme
- `dark.css` - Dark mode variant
- `3dbevel.css` - Special theme (Windows 95 style)
- `[name].css` - Any custom theme name
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
## Loading Order
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
1. System default styles
2. Theme CSS file
3. Inline style overrides (if any)
2025-11-23 09:19:06 -03:00
2025-11-23 20:12:09 -03:00
The theme system keeps styling separate from bot logic, making it easy to change the look without touching the code.
## See Also
- [Chapter 4: .gbui Interface](../chapter-04-gbui/README.md) - User interface templates
- [CSS Customization](./css.md) - Detailed styling guide
- [Theme Structure](./structure.md) - Package organization
- [Chapter 2: .gbtheme](../chapter-02/gbtheme.md) - Theme package details
- [Chapter 6: BASIC Reference](../chapter-06-gbdialog/README.md) - Script commands
- [Chapter 8: Configuration](../chapter-08-config/config-csv.md) - Bot settings