-
Notifications
You must be signed in to change notification settings - Fork 3
POC: feat: stable style for AtomLabelEditForm
#75
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
Merged
tpoisseau
merged 10 commits into
main
from
72-ensure-stable-styling-accross-integrations
Dec 19, 2025
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c17cc1e
feat: add OclReset and improves form css
tpoisseau 2610a2b
chore: simplify useCSS
tpoisseau c1e06c4
chore: add OclReset export
tpoisseau 218066c
refactor: use `<style>` instead
tpoisseau 23e9e1d
feat: improve DX with `CSS_template_literal.xml`
tpoisseau 99fb207
refactor: move reset in stories
tpoisseau b154ad1
refactor: custom `InlineStylesheet` id
tpoisseau 4326868
feat: AtomLabelEditForm migrate to emotion
tpoisseau 4dc18a2
refactor: remove styling helpers
tpoisseau ab54cff
chore: remove is-prop-valid because it's not needed
tpoisseau File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| export const greekLetters = { | ||
| alpha: 'α', | ||
| beta: 'β', | ||
| gamma: 'γ', | ||
| delta: 'δ', | ||
| epsilon: 'ε', | ||
| zeta: 'ζ', | ||
| eta: 'η', | ||
| theta: 'θ', | ||
| } as const; | ||
| const greekLetterNames = Object.keys(greekLetters); | ||
| const greeksFirstLine = greekLetterNames.slice(0, 6); | ||
| const greeksLastLine = greekLetterNames.slice(6); | ||
|
|
||
| export const primes = { | ||
| prime1: '′', | ||
| prime2: '″', | ||
| prime3: '‴', | ||
| }; | ||
| const primeNames = Object.keys(primes); | ||
|
|
||
| export const atomLabelEditCss = ` | ||
| form.react-ocl-atom-label-edit { | ||
| position: absolute; | ||
| z-index: 1; | ||
| display: grid; | ||
| grid-template-columns: repeat(4, 1.5em); | ||
| grid-template-areas: | ||
| "input input input input submit cancel" | ||
| "${greeksFirstLine.join(' ')}" | ||
| "${greeksLastLine.join(' ')} . ${primeNames.join(' ')}"; | ||
| align-items: stretch; | ||
| gap: 0.25em; | ||
| border: 1px solid lightgray; | ||
| background-color: white; | ||
| padding: 0.25em; | ||
| } | ||
|
|
||
| form.react-ocl-atom-label-edit button.react-ocl { | ||
| padding: 0.25em; | ||
| background-color: #efefef; | ||
| border: none; | ||
| border-radius: 5px; | ||
| } | ||
|
|
||
| form.react-ocl-atom-label-edit input.react-ocl { | ||
| padding: 0.25em; | ||
| border: solid 1px lightgrey; | ||
| border-radius: 3px; | ||
| } | ||
|
|
||
| form.react-ocl-atom-label-edit input.react-ocl:focus { | ||
| outline: auto; | ||
| } | ||
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import type { ReactNode } from 'react'; | ||
| import { useLayoutEffect } from 'react'; | ||
|
|
||
| import { useCSS } from '../use_css.ts'; | ||
|
|
||
| import { OclResetContext } from './ocl_reset_context.tsx'; | ||
| import { oclResetCss } from './ocl_reset_css.ts'; | ||
|
|
||
| export interface OclResetProps { | ||
| children: ReactNode; | ||
| } | ||
|
|
||
| // eslint-disable-next-line jsdoc/require-returns | ||
| /** | ||
| * Enable react-ocl-reset styles. | ||
| * @param props - The children to render | ||
| */ | ||
| export function OclReset(props: OclResetProps) { | ||
| useLayoutEffect(() => { | ||
| document.body.classList.add('react-ocl-reset'); | ||
|
|
||
| return () => { | ||
| document.body.classList.remove('react-ocl-reset'); | ||
| }; | ||
| }, []); | ||
|
|
||
| useCSS(oclResetCss); | ||
|
|
||
| return ( | ||
| <OclResetContext.Provider value>{props.children}</OclResetContext.Provider> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import { createContext } from 'react'; | ||
|
|
||
| export const OclResetContext = createContext(false); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| export const oclResetCss = ` | ||
| .react-ocl-reset input.react-ocl, .react-ocl-reset button.react-ocl { | ||
| border: none; | ||
| outline: none; | ||
| background: none; | ||
| box-sizing: border-box; | ||
| padding: 0; | ||
| margin: 0; | ||
| } | ||
| `; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import { useInsertionEffect } from 'react'; | ||
|
|
||
| /** | ||
| * Little util to inject CSS into the head. | ||
| * @param css - The CSS to inject. | ||
| */ | ||
| export function useCSS(css: string) { | ||
| useInsertionEffect(() => { | ||
| const sheet = new CSSStyleSheet(); | ||
| sheet.replaceSync(css); | ||
|
|
||
| document.adoptedStyleSheets.push(sheet); | ||
|
|
||
| return () => { | ||
| const index = document.adoptedStyleSheets.indexOf(sheet); | ||
| if (index === -1) return; | ||
|
|
||
| document.adoptedStyleSheets.splice(index, 1); | ||
| }; | ||
| }, [css]); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.