# Install the package
npm install qelements
# Or with yarn
yarn add qelements
# Or with pnpm
pnpm add qelements- Wrap your app with QElementProvider:
import React from 'react';
import { QElementProvider } from 'qelements';
function App() {
return (
<QElementProvider>
{/* Your app components */}
</QElementProvider>
);
}
export default App;- Create parent components:
import React from 'react';
import { QElementComponent, useQElementStyle } from 'qelements';
const ParentComponent = () => {
const { updateParent } = useQElementStyle('main_container_element');
const handleUpdate = () => {
// This affects ALL children with the same elementId
updateParent({
padding: 20,
margin: 10,
backgroundColor: '#f0f0f0',
borderRadius: 8
});
};
return (
<div>
<button onClick={handleUpdate}>Update Parent Style</button>
<QElementComponent elementId="main_container_element">
<p>Parent content</p>
</QElementComponent>
</div>
);
};- Create child components:
import React from 'react';
import { QElementComponent, useQElementStyle } from 'qelements';
const ChildComponent = () => {
const { override, reset } = useQElementStyle('main_container_element');
const handleOverride = () => {
// This only affects THIS specific child
override({
padding: 30,
backgroundColor: '#e3f2fd',
border: '2px solid #2196f3'
});
};
return (
<div>
<button onClick={handleOverride}>Override Child Style</button>
<button onClick={reset}>Reset to Parent</button>
<QElementComponent elementId="main_container_element">
<p>Child content</p>
</QElementComponent>
</div>
);
};import { useQElementTheme } from 'qelements';
const ThemeDemo = () => {
const { currentTheme, switchTheme, availableThemes } = useQElementTheme();
return (
<div>
<p>Current theme: {currentTheme}</p>
{availableThemes.map(theme => (
<button key={theme} onClick={() => switchTheme(theme)}>
{theme}
</button>
))}
</div>
);
};import { QElementAdvanced } from 'qelements';
const ResponsiveComponent = () => {
return (
<QElementAdvanced
elementId="responsive-demo"
responsive={{
mobile: { padding: '10px', fontSize: '14px' },
tablet: { padding: '20px', fontSize: '16px' },
desktop: { padding: '30px', fontSize: '18px' }
}}
>
<p>This adapts to screen size!</p>
</QElementAdvanced>
);
};import { QElementAdvanced, useQElementAnimation } from 'qelements';
const AnimationComponent = () => {
const { addAnimation, playAnimation } = useQElementAnimation('animated-element');
const handleAddAnimation = () => {
addAnimation('fadeIn', {
name: 'fadeIn',
duration: 1000,
timingFunction: 'ease-in-out'
});
};
return (
<div>
<button onClick={handleAddAnimation}>Add Animation</button>
<button onClick={() => playAnimation('fadeIn')}>Play Animation</button>
<QElementAdvanced
elementId="animated-element"
animations={{
fadeIn: {
name: 'fadeIn',
duration: 1000,
timingFunction: 'ease-in-out'
}
}}
>
<p>Animated content</p>
</QElementAdvanced>
</div>
);
};import { useQElementPerformance } from 'qelements';
const PerformanceComponent = () => {
const { renderCount, lastRenderTime, getPerformanceMetrics } = useQElementPerformance('monitored-element');
const handleGetMetrics = () => {
const metrics = getPerformanceMetrics();
console.log('Performance metrics:', metrics);
};
return (
<div>
<p>Render count: {renderCount}</p>
<p>Last render time: {lastRenderTime.toFixed(2)}ms</p>
<button onClick={handleGetMetrics}>Get Metrics</button>
</div>
);
};- QElementProvider: Context provider for the QElement system
- QElementComponent: Basic React component with QElement styling
- QElementAdvanced: Advanced component with all features
- useQElementStyle: Basic style management
- useQElementAdvanced: Advanced element management
- useQElementTheme: Theme management
- useQElementResponsive: Responsive design
- useQElementAnimation: Animation management
- useQElementPerformance: Performance monitoring
- QElement: Core element class
- QElementManager: Element management
- QElementThemeManager: Theme management
- QElementValidator: Style validation
- QElementResponsiveManager: Responsive utilities
qelements/
βββ dist/ # Built JavaScript & TypeScript definitions
βββ src/ # Source code
β βββ QElement.ts # Core element class
β βββ QElementManager.ts # Element management
β βββ QElementProvider.tsx # React context
β βββ QElementComponent.tsx # Basic component
β βββ QElementAdvanced.tsx # Advanced component
β βββ QElementHooks.ts # React hooks
β βββ QElementTheme.ts # Theme management
β βββ QElementValidator.ts # Style validation
β βββ QElementResponsive.ts # Responsive utilities
β βββ types.ts # TypeScript definitions
βββ examples/ # Usage examples
βββ README.md # Documentation
- Centralized Styling: Change parent styles to affect all children
- Selective Control: Override specific properties for individual children
- Type Safety: Full TypeScript support with autocomplete
- Performance: Efficient style computation and updates
- Flexibility: Works with any React component structure
- Themes: Built-in theme system with CSS variables
- Responsive: Automatic responsive design support
- Animations: Powerful animation system
- Validation: Style validation with custom rules
- Monitoring: Performance monitoring and metrics
- Install the package:
npm install qelements - Wrap your app with
QElementProvider - Use
QElementComponentorQElementAdvancedfor your elements - Use hooks to manage styles, themes, and animations
- Check the examples for advanced usage patterns
See the examples/ directory for complete working examples:
main_example.tsx- Basic parent-child relationshipbadges_screen_example.tsx- Child component with overridesadvanced-example.tsx- All advanced featuresApp.tsx- Complete demo application
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
MIT License - see LICENSE file for details
- GitHub Issues: Report bugs and request features
- Documentation: Full API documentation
- Examples: Working examples in the examples directory