Skip to content

#171 Source Card Content#178

Open
SharonStrats wants to merge 26 commits into
SolidOS:stagingfrom
SharonStrats:feat/card-content
Open

#171 Source Card Content#178
SharonStrats wants to merge 26 commits into
SolidOS:stagingfrom
SharonStrats:feat/card-content

Conversation

@SharonStrats

@SharonStrats SharonStrats commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Included

  • Typescript: Converted to typescript
  • Structure: Restructured/refactored the code to match the new design.
  • CSS: Configured babel to work like solid-ui for styles - PostCSS for web components.
  • Web Component: Created the SourceCard as a web component following the design-system web components, in order to use context, consumer implementing PR feedback a SourceProvider web component was also created.
  • CodeMirror: Integrated CodeMirror6 as the code editor.
  • Lazy Loading: lazy loaded the SourceEditor - see below for instructions to get this working in mashlib.
  • CodeMirror Extensions: Configured extensions linenumbers, history - enables the Undo and Redo state-tracking buffers, drawselection - allows you to safely style your text highlight color in dark themes using, linewrapping - Forces long lines of code to automatically wrap horizontally within the boundary of the editor container., keyboard actions - standard keyboard shortcuts like arrow key navigation, Home, End, PageUp, and PageDown and system commands for undo (Ctrl+Z / Cmd+Z) and redo (Ctrl+Y / Cmd+Y / Shift+Cmd+Z) directly to the history() buffer.
  • Configured languages: turtle, sparql, ntriples, xml, json, n3 (supported with the turtle language), JavaScript, html and css
  • Tests

Still need to do

  • export the web component class from solid-ui and use that instead of the copied version.

Getting lazy loading to work on mashlib
Note: there is more than one file currently added to pivot, browser.html, mash.css, mashlib.js, mashlib.min.js....

  • needed to add esm to source-pane
  • mashlib webpack: output: chunkFilename: '[name].js',
  • mashlib webpack: optimization: splitChunks: false - so that all the code stays in the one source-editor.js file, otherwise webpack splits out the codemirror code into it's own file (which means we'd need to maintain 2 additional chunk files instead of just the 1)
  • pivot configuration: config/customize-me.ori.json - add the source-editor.js and source-editor.js.map files just like mashlib etc. (2 entries)
  • Note: after discussion in meeting we are now adding the whole dist folder to pivot/css so we could do without the splitChunk optimization setting or the comment in the card adding the filename. I'll leave them for now.

@SharonStrats SharonStrats self-assigned this Jun 4, 2026
@SharonStrats SharonStrats added the enhancement New feature or request label Jun 4, 2026
@SharonStrats SharonStrats moved this to In progress in SolidOS NLNet UI Jun 4, 2026
@SharonStrats SharonStrats linked an issue Jun 4, 2026 that may be closed by this pull request
AI was used to for the Header which will be rewritten in another ticket
Prompt: Make the lit html and the dom manipulation work together in Header.ts
Co-authored-by: Model GPT5.4  <copilot@github.com>
will see about exporting it from solid-ui later

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR modernizes the Source Pane by migrating the implementation from a legacy DOM/textarea approach to a Lit + TypeScript component structure, introducing a CodeMirror 6-based editor, and updating the build pipeline and tests accordingly.

Changes:

  • Replaced src/sourcePane.js with a new Lit-rendered src/sourcePane.ts plus supporting modules (Header, helpers, StatusSection, types).
  • Added a CodeMirror-backed SourceEditor and a source-editor-card web component with Lit CSS module styling.
  • Updated Webpack/Babel/PostCSS setup for TypeScript + Lit decorators + *.styles.css, and refreshed/added Jest tests.

Reviewed changes

Copilot reviewed 26 out of 29 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
webpack.module.rules.mjs Adds lit-css-loader rule for *.styles.css and adjusts CSS rule exclusions.
webpack.config.mjs Switches webpack entry to TypeScript source pane entry and removes copy step.
tsconfig.json Introduces TS project configuration for the new TypeScript code.
test/sourcePane.test.js Refactors tests to assert control visibility classes and edit behavior.
test/sourceEditorCard.test.js Adds tests for the SourceEditorCard component (mocking editor + helpers).
test/sourceEditor.test.js Adds tests for the CodeMirror-backed SourceEditor (via module mocks).
test/helpers.test.js Adds unit tests for helper functions (headers parsing, fetch/metadata, UI toggling).
src/types.ts Adds shared metadata/state types for the pane.
src/StatusSection.ts Adds a Lit-rendered status/error section with show/clear helpers.
src/StatusSection.css Styles status section visibility and error message presentation.
src/sourcePane.ts New TypeScript Lit-based pane entry and render implementation.
src/sourcePane.js Removes legacy textarea-based implementation.
src/sourcePane.css Updates layout/styling to match the new component structure.
src/SourceEditor.ts Adds CodeMirror 6-based editor wrapper with language selection.
src/primitives/WebComponent.ts Adds a LitElement base with ElementInternals “states” support.
src/helpers.ts Extracts shared behaviors: response header parsing, syntax checking, control toggling, content fetch.
src/Header.ts Implements header controls (Edit/Compact/Save) for the new UI.
src/debug.ts Adds centralized log/warn/error helpers.
src/components/sourceEditor/SourceEditorCard.ts Adds the source-editor-card Lit web component integrating fetch + editor initialization.
src/components/sourceEditor/SourceEditorCard.styles.css Adds Lit CSS-module styles for the editor card presentation.
src/compactableFormats.ts Extracts compactable content-type map into its own module.
package.json Adds CodeMirror deps and build tooling for TS + Lit decorators + PostCSS/Tailwind + lit-css-loader.
package-lock.json Lockfile updates for newly added dependencies.
jest.config.mjs Broadens the ESM transform allowlist for Lit packages.
dev/index.js Updates the dev target URI used when rendering the pane locally.
declarations.d.ts Adds typings for *.styles.css and generic *.css imports.
config/postcss.mjs Adds PostCSS pipeline (Tailwind PostCSS plugin) for lit-css-loader transforms.
config/babel.mjs Adds Babel options/overrides for Lit decorators usage in selected paths.
babel.config.mjs Enables TypeScript preset and Lit decorators overrides in Babel config.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread webpack.config.mjs Outdated
Comment thread src/helpers.ts Outdated
Comment thread src/helpers.ts
Comment thread test/sourceEditorCard.test.js Outdated
Comment thread test/sourceEditor.test.js Outdated
Comment thread src/components/sourceEditor/SourceEditorCard.ts Outdated
Comment thread src/components/sourceEditorCard/SourceEditorCard.ts
Comment thread src/components/sourceEditorCard/SourceEditor.ts
Comment thread src/StatusSection.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 27 out of 30 changed files in this pull request and generated 5 comments.

Comment thread src/helpers.ts Outdated
Comment thread src/Header.ts Outdated
Comment thread src/StatusSection.ts Outdated
Comment thread src/StatusSection.ts Outdated
Comment thread src/components/sourceEditor/SourceEditor.ts Outdated

@NoelDeMartin NoelDeMartin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see this is just a draft, so I'm not reviewing everything, but I left some comments for the WIP.

Comment on lines +2 to +3
// copied from solid-ui for now so I can follow same structure as other webcomponets
// i think we need to export this, but want to talk to team

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, this should be imported from solid-ui. We could also migrate this package to use Vite like I am doing in SolidOS/solid-ui#787, but you can wait until that is merged for both.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the WebComponent isn't currently exported. I think I'll fix this in another ticket.


/* The base styles were copied from google
highlighting was modified to fit our design and needs */
const darkTheme = EditorView.theme({

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are we supporting dark themes? I know we wanted to support it at some point, but until we support it everywhere I don't think it's a good idea to start adding it to some components and others not.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was struggling with this a bit as I believe this editor dark theme belongs in the light theme for mashlib. I'll clarify at the meeting. I think I should name it something else.

Comment thread src/components/sourceEditor/SourceEditorCard.ts Outdated
Comment thread src/components/sourceEditor/SourceEditor.ts Outdated
Comment on lines +18 to +22
@property({ attribute: false })
accessor store!: LiveStore

@property({ attribute: false })
accessor subject!: NamedNode

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not sure that we should be using this type of attributes, because this only works with Lit so they won't be reusable web components. Still, I'm aware that this source pane doesn't have to be reusable as a web component... But I'm sure we'll run into similar issues with the other components.

In this case, though, I think it should be possible to obtain the store from some globals or the logged in session, right? Check out how we're using @lit/context in the solid-ui package, in particular how the auth session is obtained (we should probably introduce a Store getter in the interface, or create another context for that).

And the subject couldn't just be a string?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I added the context/consumer and changed subject to a string. I then convert it to a NamedNode when using with fetching etc.

Currently there is no auth in source-pane. I wanted to add it when working on the header because I'm thinking that the edit button shouldn't allow editing unless the user has the access (currently it lets you edit and then errors when you save).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hopefully I did this correctly. I can change it if not.

Comment thread src/StatusSection.ts
}
}

function renderStatusSection() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this new code, or has it been copied from before? Looking at the code, I think this existed before but was created using imperative APIs (createElement, etc.). If we're going to migrate it, I think we should use the new web components pattern. If it's just been moved from an existing file as-is, then I think it's ok to leave it like this for now.

@SharonStrats SharonStrats Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah i copied it over, i'm going to change it and the header over to web components in other tickets.

Update: I realized it was the error message block widget originally. I added the render function so the messages sit at the bottom of the page. I still think I should handle creating a web component and style it in another ticket. I created one now.

Comment thread src/components/sourceEditorCard/themes/dark.ts Outdated
Comment thread test/helpers.test.js
SharonStrats and others added 6 commits June 9, 2026 06:46
Prompt: Add tests for the current editor flow in SourceEditor, SourceEditorCard, and helpers. Cover initialization, read-only toggling, replace-content behavior, metadata/header handling, and the pane button visibility logic. Remove or replace any skipped tests that are now stale. Keep the tests focused on the current implementation, not the old textarea-based flow. After editing, run the test suite and fix any failing assertions.

Co-authored-by: GPT-5.4 mini <gpt-5.4-mini@openai.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Prompt: setup typescript linting

Co-authored-by: GPT-5.4 Mini <gpt-5.4-mini@openai.com>
SharonStrats and others added 7 commits June 9, 2026 13:26
Prompt: help me determine why lazy loading is not working when rolled up into mashlib

Co-authored-by: GPT-5.4 Mini <gpt-5.4-mini@openai.com>
basic implementation will extend further when working on the header
remove custom theme and add vscode themes
@timea-solid

Copy link
Copy Markdown
Member

Only comment I have - pls do not make this PR very large. Better split in multiple PRs.

@SharonStrats

Copy link
Copy Markdown
Contributor Author

Good point. I'll stop adding anything else now after I push up my current work and just create tickets for anything that's left.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 30 out of 33 changed files in this pull request and generated 9 comments.

Comment thread src/components/sourceEditorCard/SourceEditorCard.ts Outdated
Comment thread src/helpers.ts Outdated
Comment thread src/components/sourceEditorCard/SourceEditorCard.ts
Comment thread test/sourcePane.test.js
Comment thread test/sourcePane.test.js
Comment thread test/sourcePane.test.js Outdated
Comment thread test/sourcePane.test.js Outdated
Comment thread test/sourcePane.test.js Outdated
Comment thread package.json
@SharonStrats SharonStrats moved this from In progress to In review in SolidOS NLNet UI Jun 11, 2026
@SharonStrats SharonStrats marked this pull request as ready for review June 11, 2026 20:14
SharonStrats and others added 3 commits June 12, 2026 06:17
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Prompt: gave the feedback from copilot (very long can look in PR)
for testing feedback and sideEffects

Co-authored-by: GPT-5.4 Mini <gpt-5.4-mini@openai.com>
Comment thread webpack.config.mjs
],
optimization: {
minimize: true,
splitChunks: false,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We could actually do without this now that the whole dist folder is added to pivot and css. Even if set here though mashlib will still split in 2 chunks if the setting isn't turned on there as well.

return
}
try {
const { SourceEditor } = await import(/* webpackChunkName: "source-editor" */ './SourceEditor')

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Since we expose the whole dist folder we also don't need to add the comment because it won't matter what the file name is. Wondering if I should delete it or if it matters?

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

Status: In review

Development

Successfully merging this pull request may close these issues.

overall Card and content display

4 participants