| |
| const state = { |
| currentProject: 'Espace Codage - Projet 1', |
| tools: ['La Baleine', 'Rosalinda', 'CodeExplainer', 'ThemeGenerator'], |
| currentTool: null, |
| generatedCode: '', |
| codeExplanation: '', |
| generatedImage: null |
| }; |
|
|
| |
| const elements = { |
| sidebar: document.querySelector('custom-sidebar'), |
| codeExplanation: document.querySelector('custom-code-explanation'), |
| imageGenerator: document.querySelector('custom-image-generator') |
| }; |
|
|
| |
| document.addEventListener('DOMContentLoaded', () => { |
| |
| updateUI(); |
| }); |
|
|
| function updateUI() { |
| |
| if (elements.sidebar) { |
| elements.sidebar.setAttribute('current-project', state.currentProject); |
| elements.sidebar.setAttribute('current-tool', state.currentTool || ''); |
| } |
| |
| if (elements.codeExplanation) { |
| elements.codeExplanation.setAttribute('explanation', state.codeExplanation); |
| elements.codeExplanation.setAttribute('generated-code', state.generatedCode); |
| } |
| |
| if (elements.imageGenerator) { |
| elements.imageGenerator.setAttribute('image-data', state.generatedImage || ''); |
| } |
| } |
|
|
| |
| function generateCodeExplanation(code) { |
| |
| return `The generated CSS defines visual styles for the application: |
| - Background color: Sets the main background |
| - Scrollbar: Customizes the scrollbar appearance |
| - Animations: Adds subtle pulse animation |
| - Transitions: Smooth hover effects`; |
| } |
|
|
| |
| function generateImageFromCode(code) { |
| |
| return 'http://static.photos/technology/640x360/42'; |
| } |
|
|
| |
| window.appState = { |
| ...state, |
| updateUI, |
| generateCodeExplanation, |
| generateImageFromCode |
| }; |