Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add file navigation, sass compilation and exporting #6

Merged
merged 4 commits into from
Apr 9, 2024

Conversation

jboix
Copy link
Contributor

@jboix jboix commented Apr 8, 2024

Description

Resolves #4 by introducing the following features:

  1. File navigation for accessing the latest version of Pillarbox files within the editor
  2. Real-time compilation from SCSS to CSS upon editing SCSS files, with immediate updates to the rendered view.
  3. Exporting the current work as a ZIP.
image

Changes Made

  • Introduced SassWorkspaceCompiler for SASS compilation and virtual workspace management.
  • Implemented VirtualSassImporter to resolve import directives in a virtual file system.
  • Enabled inclusion of static resources in SASS compilation.
  • Added a prebuild script to generate virtual workspace structure from @srgssr/pillarbox-web SCSS files.
  • Introduced TogglePaneButton component for theme editor file navigation.
  • Added functionality to display and edit SCSS files from a virtual file system in the theme editor.
  • Introduces a ZipWorkspace service to allow the exporting of the current workspace as a zip.

Checklist

  • I have followed the project's style and contribution guidelines.
  • I have performed a self-review of my own changes.
  • I have made corresponding changes to the documentation.
  • I have added tests that prove my fix is effective or that my feature works.

Introduces the SassWorkspaceCompiler to allow SASS compilation and workspace management. This
utility facilitates the compilation of SASS files using a virtual file system, it allows the
inclusion of static resources.

The VirtualSassImporter, implementing the Importer interface, efficiently resolves import directives
within this virtual file system.

***Example***

```javascript
// Define your workspace
const workspace = [
  {
    name: 'main.scss',
    content: '@import "variables"; .body { color: $primaryColor; }',
    type: 'scss'
  },
  {
    name: 'variables.scss',
    content: '$primaryColor: blue;',
    type: 'scss'
  }
];

// Instantiate the compiler with the workspace
const compiler = new SassWorkspaceCompiler(testWorkspace, {}, 'main.scss');

// Compile the SCSS
const compiledCss = compiler.compile();
```

Additionally, a prebuild script has been introduced to automate the generation of the virtual
workspace structure directly from the `@srgssr/pillarbox-web` dependency's SCSS files.
@jboix jboix self-assigned this Apr 8, 2024
Copy link

github-actions bot commented Apr 8, 2024

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 91.77% 781 / 851
🔵 Statements 91.77% 781 / 851
🔵 Functions 90.74% 49 / 54
🔵 Branches 89.87% 71 / 79
File Coverage
File Stmts % Branch % Funcs % Lines Uncovered Lines
Changed Files
src/index.js 0% 0% 0% 0% 1-33
src/components/css-editor.js 89.43% 76.92% 81.81% 89.43% 9-14, 73-74, 101-106, 137
src/components/preview-box.js 100% 100% 100% 100%
src/components/resizable-bar.js 96.87% 100% 80% 96.87% 55-56
src/components/toggle-pane-button.js 100% 100% 100% 100%
src/components/tree-view.js 100% 100% 100% 100%
src/workspace/sass-workspace-compiler.js 100% 100% 100% 100%
src/workspace/virtual-sass-importer.js 95.09% 70% 100% 95.09% 22, 47-48, 81-82
src/workspace/workspace.js 0% 0% 0% 0% 1-15
src/workspace/zip-workspace.js 100% 100% 100% 100%
Generated in workflow #21

@jboix jboix force-pushed the feat/sass-compilation branch 2 times, most recently from 6e17551 to cecf313 Compare April 8, 2024 08:41
@jboix jboix requested a review from amtins April 8, 2024 08:43
@jboix jboix marked this pull request as ready for review April 8, 2024 08:43
@jboix jboix force-pushed the feat/sass-compilation branch from cecf313 to 6e87939 Compare April 8, 2024 08:50
@jboix jboix added the enhancement New feature or request label Apr 8, 2024
Copy link

github-actions bot commented Apr 8, 2024

PR Preview Action v1.4.7
Preview removed because the pull request was closed.
2024-04-09 12:56 UTC

jboix added 2 commits April 8, 2024 17:24
Introduces a new `TogglePaneButton` component, aimed at displaying a virtual file system in order to
edit the multiple `scss` files found in the pillarbox default theme. When a file in the tree view is
selected, its content is loaded into the theme editor for modification and previewing.

***Example***
```html
<toggle-pane-button label="Display a message">
  <span>Hello World!</span>
</toggle-pane-button>
```
Introduces a new `ZipWorkspace` service to allow the exporting of the current workspace as a zip.

***Example***

```javascript
// Define your workspace
const workspace = [
  {
    name: 'main.scss',
    content: '@import "variables"; .body { color: $primaryColor; }',
    type: 'scss'
  },
  {
    name: 'variables.scss',
    content: '$primaryColor: blue;',
    type: 'scss'
  }
];

// Instantiate the zip workspace and trigger the download
await new ZipWorkspace(testWorkspace).download('testWorkspace.zip');
```
@jboix jboix force-pushed the feat/sass-compilation branch from 6e87939 to 91acbcb Compare April 8, 2024 15:24
@jboix jboix changed the title Feat/sass compilation feat: add file navigation, sass compilation and exporting Apr 9, 2024
@amtins
Copy link
Member

amtins commented Apr 9, 2024

There's one use case that would be interesting to handle, it could be part of a different PR, and that's being able to change the media.

Today I can't change the appearance of subtitles or live layout.

npm offers `pre` and `post` scripts that will run automatically before or after a script.

Co-authored-by: André M. <[email protected]>
@jboix jboix requested a review from amtins April 9, 2024 12:47
Copy link
Member

@amtins amtins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jboix jboix added this pull request to the merge queue Apr 9, 2024
Merged via the queue into main with commit 195632a Apr 9, 2024
2 checks passed
@jboix jboix deleted the feat/sass-compilation branch April 9, 2024 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Pillarbox SCSS File Integration
2 participants