Files
metabuilder/qml/components/layout/CBox.qml
johndoe6345789 c406b8df96 refactor: Reorganize FakeMUI by implementation type
Move FakeMUI content to appropriate root-level folders by implementation:

**React Components → components/fakemui/**
- 537 components (inputs, surfaces, layout, data-display, feedback,
  navigation, utils, atoms, lab, x, email, workflows)
- 416 SVG icons
- Full barrel exports in components/fakemui/index.ts

**QML Components → qml/**
- 104 Material Design 3 components (11 categories)
- 7 hybrid application views
- 8 desktop widgets
- qmldir module registration

**Python Bindings → python/fakemui/**
- 15 PyQt6 modules (120+ components)
- Full Python package structure with pyproject.toml

**SCSS/Styles → fakemui/** (renamed purpose)
- scss/ - Material Design 3 stylesheets
- styles/ - Component SCSS modules
- src/utils/ - Accessibility utilities
- index.ts now re-exports from components/fakemui/

This separation allows:
- React: import { Button } from '@metabuilder/components/fakemui'
- QML: import QmlComponents 1.0
- Python: from fakemui import Button, Card
- Backward compat: import { Button } from '@metabuilder/fakemui'

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 12:59:24 +00:00

112 lines
3.6 KiB
QML

import QtQuick
/**
* CBox.qml - Generic container component (mirrors common SCSS patterns)
* Flexible container with padding, margin, and styling options
*
* Usage:
* CBox {
* padding: "md"
* background: "paper"
* radius: "sm"
*
* Text { text: "Content" }
* }
*/
Rectangle {
id: root
// Public properties
property string padding: "none" // none, xs, sm, md, lg, xl or number
property string paddingX: "" // Horizontal padding override
property string paddingY: "" // Vertical padding override
property string background: "transparent" // transparent, paper, surface, elevated, primary, or color
property string radius: "none" // none, sm, md, lg, full or number
property string borderColor: "" // Border color (empty = no border)
property int borderWidth: 1
property string shadow: "none" // none, sm, md, lg
// Content slot
default property alias content: contentItem.data
// Padding calculations
readonly property int _paddingH: {
var p = paddingX || padding
switch (p) {
case "none": return 0
case "xs": return StyleVariables.spacingXs
case "sm": return StyleVariables.spacingSm
case "md": return StyleVariables.spacingMd
case "lg": return StyleVariables.spacingLg
case "xl": return StyleVariables.spacingXl
default: return parseInt(p) || 0
}
}
readonly property int _paddingV: {
var p = paddingY || padding
switch (p) {
case "none": return 0
case "xs": return StyleVariables.spacingXs
case "sm": return StyleVariables.spacingSm
case "md": return StyleVariables.spacingMd
case "lg": return StyleVariables.spacingLg
case "xl": return StyleVariables.spacingXl
default: return parseInt(p) || 0
}
}
// Background color
color: {
switch (background) {
case "transparent": return "transparent"
case "paper": return Theme.paper
case "surface": return Theme.surface
case "elevated": return Theme.surfaceVariant
case "primary": return Theme.primary
case "error": return Theme.error
case "success": return Theme.success
case "warning": return Theme.warning
default: return background // Allow custom color
}
}
// Border radius
radius: {
switch (root.radius) {
case "none": return 0
case "sm": return StyleVariables.radiusSm
case "md": return StyleVariables.radiusMd
case "lg": return StyleVariables.radiusLg
case "full": return StyleVariables.radiusFull
default: return parseInt(root.radius) || 0
}
}
// Border
border.width: borderColor ? borderWidth : 0
border.color: {
switch (borderColor) {
case "": return "transparent"
case "default": return Theme.border
case "divider": return Theme.divider
case "primary": return Theme.primary
default: return borderColor
}
}
// Size based on content
implicitWidth: contentItem.implicitWidth + _paddingH * 2
implicitHeight: contentItem.implicitHeight + _paddingV * 2
// Content wrapper with padding
Item {
id: contentItem
anchors.fill: parent
anchors.leftMargin: root._paddingH
anchors.rightMargin: root._paddingH
anchors.topMargin: root._paddingV
anchors.bottomMargin: root._paddingV
}
}