Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="grid">
	<div class="grid-col">
		<section class="controls">
			<h2>Building Blocks</h2>
			<button class="and" data-description="p and q" data-selector=".p.q">p ^ q</button>
			<button class="or" data-description="p or q" data-selector=".p, .q">p v q</button>
			<button class="not-p" data-description="not p" data-selector="*:not(.p)">~p</button>
			<button class="not-q" data-description="not q" data-selector="*:not(.q)">~q</button>
			<button class="implication" data-description="if p then q / p implies q" data-selector=".p .q">p &rarr; q</button>
			<button class="implication-alt" data-description="if q then p / q implies p" data-selector=".q .p">q &rarr; p</button>
			<h2>Sugar</h2>
			<button class="exclusive" data-description="p or q but not both" data-selector="*:not(.p), *:not(.q)">p ø q<br>(p v q) ^ (~p ^ ~q)</button>
			<button class="biconditional" data-description="How to do this??? p if and only if q" data-selector=".p + .q .p, .q + .p .q">p ⇔ q <br>(p &rarr; q) ^ (q &rarr; p)</button>

			<h2>Expressions</h2>
			<button class="not-p-and-not-q" data-description="not p and not q" data-selector="*:not(.p):not(.q)">~p ^ ~q</button>
		</section>
	</div>
	<section class="grid-col">
		<h2>Statments</h2>
		<div class="flex flex-column">
			<p>description: <span class="data-description"></span></p>
			<p>selector: <code class="data-selector"></code></p>
		</div>
		<div class="statements">
			<b class="p"></b>
			<b class="q"></b>
			<b class="p q"></b>
			<b class="r"></b>
			<b class="p">
				<b class="q"></b>
			</b>
			<b class="q">
				<b class="p"></b>
			</b>
			<b class="r">
				<b class="p">
					<b class="q"></b>
				</b>
				<b class="q">
					<b class="p"></b>
				</b>
			</b>
		</div>
	</section>
</div>

<script type="module">

</script>
              
            
!

CSS

              
                body {
	font-family: -apple-system, system-ui, Arial,sans-serif;
}

* {
	background-color: var( --background-color, initial );
	color: var( --color, initial );
}

// p ^ q - and

.and {
	.p.q {
		--background-color: green;
	}
}

// p v q - or
.or	{
	.p, .q {
		--background-color: green;
	}
}

// p ø q - xor
.exclusive {
	.p:not(.q),
	.q:not(.p) {
		--background-color: green;
	}
}

.implication {
	.p .q {
		--background-color: green;	
	}
}

.implication-alt {
	.q .p {
		--background-color: green;	
	}
}

// ~p
.not-p {
	*:not(.p) {
		--background-color: green;
	}
}

// ~q
.not-q {
	*:not(.q) {
		--background-color: green;
	}
}

.not-p-and-not-q {
	*:not(.p):not(.q) {
		--background-color: green;
	}
}

// p ⇔ q - p if and only if q
// p -> q ^ q -> p
// if p then q
// and
// if q then p
.biconditional {
	.p ~ .q {
		--background-color: green;
	}
}

.selected {
	--background-color: blue;
	--color: white;
}

b {
	--background-color: black;
	--color: white;
	padding: 10px;
	display: flex;
	height: 100%;
	border: 2px solid limegreen;
	display: inline-block;
	
	&::before {
		display: block;
		margin-bottom: 5px;
		content: 'class="' attr(class) '"';
		font-family: monospace;
	}
}

.statements {
	margin-top: 10px;
	gap: 5px;
	align-items: center;
}

.grid {
	display: grid;
	grid-template-columns: 300px 1fr;
}

.flex {
	display: flex;
}

.flex-column {
	flex-direction: column;
}

h2 {
	font-size: 1.2rem;
	text-transform: uppercase;
}

              
            
!

JS

              
                import {finder} from 'https://medv.io/finder/finder.js';

const $ = (el) => document.querySelectorAll(el)[0];

$( '.controls' ).addEventListener( 'click', ( e ) => {
	
	// Reset button classes
	document.querySelectorAll( 'button' ).forEach( el => el.classList.remove( 'selected' ) );
	
	if ( e.target.nodeName == 'BUTTON' ) {

		e.target.classList.add( 'selected' );
		
		// Clear the slate
		$( '.statements' ).classList = 'statements';
		$( '.data-description' ).text = '';
		$( '.data-selector' ).text = '';

		// Add new data
		$( '.statements' ).classList.add(e.target.classList[0] );
		$( '.data-description' ).innerHTML = 
				`${e.target.classList[0]} (<em>${e.target.dataset.description}</em>)`;
		$( '.data-selector' ).innerHTML = 
				`${e.target.dataset.selector}`;
	}
		
} );



              
            
!
999px

Console