- Add Pinia state management - Create centralized stylesheet store with utility methods - Extract CSS parsing utilities to src/utils/css-parsing.js - Refactor ElementPopup to manage state independently via store - Simplify App.vue by removing prop drilling - Fix iframe rendering with srcdoc instead of document.write - Improve API: updateProperty uses object parameter for clarity 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
38 lines
934 B
JavaScript
38 lines
934 B
JavaScript
import { defineStore } from 'pinia';
|
|
import { ref } from 'vue';
|
|
import cssParsingUtils from '../utils/css-parsing';
|
|
|
|
export const useStylesheetStore = defineStore('stylesheet', () => {
|
|
const content = ref('');
|
|
|
|
const loadStylesheet = async () => {
|
|
const response = await fetch('/assets/css/stylesheet.css');
|
|
content.value = await response.text();
|
|
};
|
|
|
|
const updateProperty = (selector, property, value, unit) => {
|
|
content.value = cssParsingUtils.updateCssValue({
|
|
css: content.value,
|
|
selector,
|
|
property,
|
|
value,
|
|
unit
|
|
});
|
|
};
|
|
|
|
const extractValue = (selector, property) => {
|
|
return cssParsingUtils.extractCssValue(content.value, selector, property);
|
|
};
|
|
|
|
const extractBlock = (selector) => {
|
|
return cssParsingUtils.extractCssBlock(content.value, selector);
|
|
};
|
|
|
|
return {
|
|
content,
|
|
loadStylesheet,
|
|
updateProperty,
|
|
extractValue,
|
|
extractBlock
|
|
};
|
|
});
|