Skip to content

Commit

Permalink
Prefer className instead of class
Browse files Browse the repository at this point in the history
For portability with React JSX, and for parity with how Emmet generates
JSX.
  • Loading branch information
caleb531 committed Aug 19, 2024
1 parent 576daa9 commit 58670bb
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
8 changes: 4 additions & 4 deletions scripts/components/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ class AppComponent {
view() {
return (
<div id="app" onclick={(clickEvent) => this.toggleReference(clickEvent)}>
<span id="reference-link" class="nav-link nav-link-left">
<a href="#" class="reference-open-control">App Reference</a>
<span id="reference-link" className="nav-link nav-link-left">
<a href="#" className="reference-open-control">App Reference</a>
</span>
<span id="personal-site-link" class="nav-link nav-link-right">
<span id="personal-site-link" className="nav-link nav-link-right">
by <a href="https://calebevans.me/">Caleb Evans</a>
</span>
<h1>Truthy</h1>
<ReferenceComponent app={this.app} referenceIsOpen={this.referenceIsOpen} />
<h2>Variables</h2>
<VariableCollectionComponent app={this.app} />
<h2>Table</h2>
<div class="scrollable-container">
<div className="scrollable-container">
<TableComponent app={this.app} />
</div>
<p>
Expand Down
12 changes: 6 additions & 6 deletions scripts/components/reference.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@ class ReferenceComponent {

view({ attrs: { app, referenceIsOpen } }) {
return (
<div id="reference" class={clsx(
<div id="reference" className={clsx(
'reference-close-control',
{ 'reference-is-open': referenceIsOpen }
)}>
<div id="reference-sidebar" class="scrollable-container" onclick={(clickEvent) => this.tryExample(clickEvent, app)}>
<img class="reference-close-control" src={closeIconUrl} alt="Close" />
<div id="reference-sidebar" className="scrollable-container" onclick={(clickEvent) => this.tryExample(clickEvent, app)}>
<img className="reference-close-control" src={closeIconUrl} alt="Close" />
<h2>App Reference</h2>
<p class="cta">Click any example to try it!</p>
<p className="cta">Click any example to try it!</p>
{ReferenceComponent.features.map((feature) => {
return (
<div class="feature">
<div className="feature">
<h3>{feature.name}</h3>
{feature.examples.map((example) => {
return <pre class="feature-example reference-close-control">{example}</pre>;
return <pre className="feature-example reference-close-control">{example}</pre>;
})}
</div>
);
Expand Down
14 changes: 7 additions & 7 deletions scripts/components/table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ class TableComponent {
<thead>
<tr onclick={(clickEvent) => this.handleControls(clickEvent)} oninput={(inputEvent) => this.updateExpressionString(inputEvent)}>
{this.app.variables.map((variable) => {
return <th class="variable">{variable.name ? variable.name : '?'}</th>;
return <th className="variable">{variable.name ? variable.name : '?'}</th>;
})}
{this.app.expressions.map((expression, e) => {
return (
<th class="expression" data-index={e}>
<div class="has-controls">
<div class="control control-add"></div>
{this.app.expressions.length > 1 ? <div class="control control-remove"></div> : null}
<th className="expression" data-index={e}>
<div className="has-controls">
<div className="control control-add"></div>
{this.app.expressions.length > 1 ? <div className="control control-remove"></div> : null}
<input type="text" size={Math.max(1, expression.string.length)} value={expression.string} autocapitalize="off" autocomplete="off" autocorrect="off" spellcheck="false" oncreate={(vnode) => this.focusNewExpression(vnode)} onupdate={(vnode) => this.focusNewExpression(vnode)} data-index={e} />
</div>
</th>
Expand All @@ -95,7 +95,7 @@ class TableComponent {
{this.app.variables.map((variable) => {
let varValue = varValues[variable.name];
return (
<td class={clsx({
<td className={clsx({
true: varValue === true,
false: varValue === false
})}>
Expand All @@ -106,7 +106,7 @@ class TableComponent {
{this.app.expressions.map((expression) => {
let exprValue = expression.evaluate(varValues);
return (
<td class={clsx({
<td className={clsx({
true: exprValue === true,
false: exprValue === false,
invalid: exprValue === null
Expand Down
8 changes: 4 additions & 4 deletions scripts/components/variable-collection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ class VariableCollectionComponent {
<div id="variables" onclick={(clickEvent) => this.handleControls(clickEvent)} oninput={(inputEvent) => this.updateVariableName(inputEvent)}>
{this.app.variables.map((variable, v) => {
return (
<div class="variable" data-index={v}>
<div class="has-controls">
<div class="control control-add"></div>
{this.app.variables.length > 1 ? <div class="control control-remove"></div> : null}
<div className="variable" data-index={v}>
<div className="has-controls">
<div className="control control-add"></div>
{this.app.variables.length > 1 ? <div className="control control-remove"></div> : null}
<input type="text" value={variable.name} maxlength={1} autocapitalize="off" autocomplete="off" autocorrect="off" spellcheck="false" oncreate={(vnode) => this.focusNewVariable(vnode)} onupdate={(vnode) => this.focusNewVariable(vnode)} data-index={v} />
</div>
</div>
Expand Down

0 comments on commit 58670bb

Please sign in to comment.