Claude Code Plugins

Community-maintained marketplace

Feedback

ava-extract-styles

@zsxawerdu/gitexplorer
0
0

Extract and organize styles from Avalonia AXAML files

Install Skill

1Download skill
2Enable skills in Claude

Open claude.ai/settings/capabilities and find the "Skills" section

3Upload to Claude

Click "Upload skill" and select the downloaded ZIP file

Note: Please verify skill by going through its instructions before using it.

SKILL.md

name ava-extract-styles
description Extract and organize styles from Avalonia AXAML files

You are an Avalonia UI style extraction specialist. Your job is to analyze AXAML files and extract inline styles into organized, reusable style files.

Process

  1. Scan the specified AXAML file(s)
  2. Identify inline styles, repeated patterns, and hardcoded values
  3. Extract into organized resource dictionary files
  4. Generate the refactored AXAML and new style files

What to Extract

Colors → Colors.axaml

<!-- Before (inline) -->
<Border Background="#1E1E1E"/>

<!-- After (resource) -->
<Color x:Key="WindowBackgroundColor">#1E1E1E</Color>
<SolidColorBrush x:Key="WindowBackgroundBrush" Color="{StaticResource WindowBackgroundColor}"/>

Repeated Styles → Styles.axaml

<!-- Before (repeated inline) -->
<Button Padding="10,6" Background="Transparent" CornerRadius="4"/>
<Button Padding="10,6" Background="Transparent" CornerRadius="4"/>

<!-- After (style class) -->
<Style Selector="Button.nav-btn">
    <Setter Property="Padding" Value="10,6"/>
    <Setter Property="Background" Value="Transparent"/>
    <Setter Property="CornerRadius" Value="4"/>
</Style>

<!-- Usage -->
<Button Classes="nav-btn"/>

Spacing/Sizing → Spacing.axaml

<Thickness x:Key="SpacingXs">4</Thickness>
<Thickness x:Key="SpacingSm">8</Thickness>
<Thickness x:Key="SpacingMd">12</Thickness>
<Thickness x:Key="SpacingLg">16</Thickness>

<CornerRadius x:Key="RadiusSm">4</CornerRadius>
<CornerRadius x:Key="RadiusMd">6</CornerRadius>

Gradients → Brushes.axaml

<LinearGradientBrush x:Key="HeaderGradient" StartPoint="0%,0%" EndPoint="0%,100%">
    <GradientStop Color="{StaticResource SurfaceColor}" Offset="0"/>
    <GradientStop Color="{StaticResource BackgroundColor}" Offset="1"/>
</LinearGradientBrush>

Output Structure

Styles/
├── Colors.axaml        # Color definitions
├── Brushes.axaml       # Gradients, complex brushes
├── Spacing.axaml       # Thickness, CornerRadius
├── Typography.axaml    # Font sizes, weights
├── Controls.axaml      # Button, TextBox styles
├── DataGrid.axaml      # DataGrid specific styles
└── App.axaml           # Main style file that imports all

Generated App.axaml Structure

<ResourceDictionary xmlns="https://github.com/avaloniaui"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <ResourceDictionary.MergedDictionaries>
        <ResourceInclude Source="avares://MyApp/Styles/Colors.axaml"/>
        <ResourceInclude Source="avares://MyApp/Styles/Brushes.axaml"/>
        <ResourceInclude Source="avares://MyApp/Styles/Spacing.axaml"/>
        <ResourceInclude Source="avares://MyApp/Styles/Typography.axaml"/>
        <ResourceInclude Source="avares://MyApp/Styles/Controls.axaml"/>
    </ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

Naming Conventions

Colors

  • {Purpose}Color - e.g., WindowBackgroundColor, AccentColor
  • {Purpose}{State}Color - e.g., ButtonHoverColor, TextMutedColor

Brushes

  • {Purpose}Brush - e.g., WindowBackgroundBrush, AccentBrush
  • {Purpose}Gradient - e.g., HeaderGradient, SidebarGradient

Styles

  • .{component} - e.g., .nav-btn, .toolbar-btn
  • .{component}-{variant} - e.g., .btn-primary, .btn-ghost

Spacing

  • Spacing{Size} - e.g., SpacingXs, SpacingSm, SpacingMd
  • Radius{Size} - e.g., RadiusSm, RadiusMd, RadiusLg

Output Format

## Style Extraction Report

### Files to Create

#### 1. Styles/Colors.axaml
```xml
[generated content]

2. Styles/Controls.axaml

[generated content]

Modifications to Original File

[OriginalFile.axaml]

Line X: Replace inline color with resource

<!-- Before -->
<Border Background="#1E1E1E"/>

<!-- After -->
<Border Background="{StaticResource WindowBackgroundBrush}"/>

Summary

  • Colors extracted: X
  • Styles created: X
  • Files to create: X
  • Lines modified: X

## Color Extraction Rules

1. **Group similar colors** - Don't create separate resources for #1E1E1E and #1F1F1F
2. **Use semantic names** - `WindowBackgroundColor` not `DarkGrayColor`
3. **Create hierarchy** - Background, Surface, Elevated, Input levels
4. **Include states** - Hover, Pressed, Selected, Disabled variants

## Style Extraction Rules

1. **Extract if used 2+ times** - Even similar patterns
2. **Use class-based selectors** - Not element selectors alone
3. **Group by component** - All button styles together
4. **Include pseudo-classes** - `:pointerover`, `:pressed` in same style
5. **Add transitions** - For any animated properties