styling_optimizer
styling_optimizer ¶
AppStudio styling optimizer — presets and batch styling for AppStudio apps.
Provides pre-built style presets and functions to apply them consistently across an AppStudio app's definition and all view layouts.
Usage
from crew_dcs.classes.DomoAppStudio.styling_optimizer import ( AppStudioStylePreset, PRESETS, apply_preset_to_definition, apply_preset_to_layout, optimize_app, )
Apply a preset to an app¶
app = await DomoAppStudio.get_by_id(auth=auth, appstudio_id='667742883') await optimize_app(app, preset=PRESETS["MINIMAL_LIGHT"], save=True)
Or use the convenience method on the app itself¶
await app.optimize_style(preset_name="minimal_light", save=True)
Or apply to just the definition¶
await app.Definition.apply_style(preset=PRESETS["EXECUTIVE"])
AppStudioStylePreset
dataclass
¶
AppStudioStylePreset(
name: str,
nav_orientation: str = "TOP",
show_domo_navigation: bool = False,
show_logo: bool = True,
show_title: bool = True,
background_color: str = "#FFFFFF",
text_color: str = "#333333",
dark_mode: bool = False,
hide_borders: bool = True,
hide_margins: bool = True,
hide_footers: bool = True,
fit_to_frame: bool = True,
card_spacing: int = 4,
)
Pre-built styling configuration for AppStudio apps.
Captures the most common styling knobs in a single object so they can be applied consistently to both the app definition and every view layout.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Human-readable preset name. |
nav_orientation |
str
|
Navigation bar position — TOP, LEFT, RIGHT, BOTTOM. |
show_domo_navigation |
bool
|
Whether to show the Domo chrome navigation bar. |
show_logo |
bool
|
Whether to show the instance logo. |
show_title |
bool
|
Whether to show the app title. |
background_color |
str
|
Hex color for the page background. |
text_color |
str
|
Hex color for text on the background. |
dark_mode |
bool
|
Whether the background is dark (affects Domo rendering). |
hide_borders |
bool
|
Whether to hide card borders. |
hide_margins |
bool
|
Whether to hide card margins. |
hide_footers |
bool
|
Whether to hide card footers. |
fit_to_frame |
bool
|
Whether cards should fit to their frame. |
card_spacing |
int
|
Page density / card spacing in pixels. |
apply_preset_to_definition ¶
apply_preset_to_definition(
definition: AppStudioDefinition,
preset: AppStudioStylePreset,
) -> AppStudioDefinition
Apply a style preset to an AppStudioDefinition.
Mutates the definition in-place and returns it for chaining.
Sets
- nav_orientation
- show_domo_navigation
- show_logo
- show_title
- theme (updated with background_color and text_color if present)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
definition
|
AppStudioDefinition
|
The AppStudioDefinition to modify. |
required |
preset
|
AppStudioStylePreset
|
The style preset to apply. |
required |
Returns:
| Type | Description |
|---|---|
AppStudioDefinition
|
The same definition object, mutated in-place. |
Source code in src/crew_dcs/classes/DomoAppStudio/styling_optimizer.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
apply_preset_to_layout ¶
apply_preset_to_layout(
layout, preset: AppStudioStylePreset
)
Apply a style preset to a PageLayout.
Mutates the layout in-place and returns it for chaining.
Sets
- background.selected_color, text_color, is_darkMode
- For each CARD content: hide_border, hide_margins, hide_footer, fit_to_frame
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layout
|
The PageLayout to modify. |
required | |
preset
|
AppStudioStylePreset
|
The style preset to apply. |
required |
Returns:
| Type | Description |
|---|---|
|
The same layout object, mutated in-place. |
Source code in src/crew_dcs/classes/DomoAppStudio/styling_optimizer.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | |
get_preset_by_name ¶
get_preset_by_name(name: str) -> AppStudioStylePreset
Look up a preset by name (case-insensitive).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Preset name, e.g. "minimal_light" or "MINIMAL_LIGHT". |
required |
Returns:
| Type | Description |
|---|---|
AppStudioStylePreset
|
The matching AppStudioStylePreset. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no preset matches the given name. |
Source code in src/crew_dcs/classes/DomoAppStudio/styling_optimizer.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
optimize_app
async
¶
optimize_app(
app,
preset: AppStudioStylePreset | None = None,
save: bool = True,
*,
context: RouteContext | None = None,
**context_kwargs
) -> AppStudioDefinition
Apply a style preset to an entire AppStudio app.
Fetches the definition (if not already loaded), applies the preset to the definition, fetches all views, applies the preset to each view's layout, and optionally saves all changes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app
|
A DomoAppStudio instance. |
required | |
preset
|
AppStudioStylePreset | None
|
The style preset to apply. Defaults to MINIMAL_LIGHT. |
None
|
save
|
bool
|
If True, saves definition and layout changes to the API. |
True
|
context
|
RouteContext | None
|
Optional RouteContext for request configuration. |
None
|
**context_kwargs
|
Additional context parameters. |
{}
|
Returns:
| Type | Description |
|---|---|
AppStudioDefinition
|
The AppStudioDefinition after applying the preset. |
Source code in src/crew_dcs/classes/DomoAppStudio/styling_optimizer.py
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | |