website/src/styles/demos/computer.css (7530B)
/* The 8-bit computer: its controls, then Ben Eater's layout */ .sim-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 10px; margin-bottom: 12px; font-size: 12px; } /* board: Ben Eater's layout, two columns of modules either side of the bus */ .board { --led: 10px; /* the RAM row editor is placed over it */ position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 64px minmax(0, 1fr); grid-template-areas: "left bus right"; gap: 10px; font-size: 11.5px; font-variant-numeric: tabular-nums; } .col { display: flex; flex-direction: column; gap: 10px; } .col-l { grid-area: left; } .col-r { grid-area: right; } /* the clock with the microstep counter beside it, and the program counter with the flags; short of room, their control lines go under their names */ .mod-pair { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; } .mod-pair .mod-head { flex-wrap: wrap; row-gap: 2px; } .mod { padding: 7px 10px 9px; border: 1px solid var(--rule); background: color-mix(in srgb, var(--bg) 92%, var(--fg)); } .mod.is-out { border-color: var(--red); } .mod.is-in { border-color: var(--green); } .mod-head { display: flex; align-items: baseline; gap: 1ch; margin-bottom: 6px; color: var(--dim); white-space: nowrap; } .mod-name { margin-right: auto; overflow: hidden; text-overflow: ellipsis; } .sigs { display: flex; gap: 1ch; } .sig { padding: 0 0.4ch; border-radius: 2px; color: var(--dim); font-size: 11px; } .sig.on { background: var(--blue); color: var(--bg); } .mod-body { display: flex; align-items: center; justify-content: space-between; gap: 1ch; } .mod-val { color: var(--fg); white-space: nowrap; } .leds { display: flex; gap: calc(var(--led) * 0.45); } .led { display: block; flex: none; width: var(--led); height: var(--led); padding: 0; border: 0; border-radius: 50%; background: var(--led-off); --lc: var(--red); } .led.on { background: var(--lc); box-shadow: 0 0 calc(var(--glow) * 7px) calc(var(--glow) * 1px) color-mix(in srgb, var(--lc) 70%, transparent); } .led.g { --lc: var(--green); } .led.y { --lc: var(--yellow); } .led.b { --lc: var(--blue); } .leds .gap { width: calc(var(--led) * 0.4); } /* RAM: the whole 16-byte memory as a matrix you can edit */ .ram-rows { display: grid; gap: 1px; } .ram-row { --led: 8px; display: grid; grid-template-columns: 1.5ch 2ch auto minmax(0, 1fr); align-items: center; gap: 0.8ch; padding: 1px 4px; margin: 0 -4px; line-height: 14px; } .ram-row.is-mar { background: var(--hl); } .ram-row .pc { color: var(--green); } .ram-row .addr { color: var(--dim); } .ram-row .dis { overflow: hidden; color: var(--dim); white-space: nowrap; text-overflow: ellipsis; } .ram-row.is-mar .dis { color: var(--fg); } .ram-row .led { cursor: pointer; } @media (hover: hover) { .ram-row .led:hover { outline: 1px solid var(--faint); outline-offset: 1px; } } /* An off bit gets a ring, so the zeros you can set still show: the off colour alone is about 1.1:1 on the module. A lit bit stays a filled dot. */ .ram-row .led:not(.on), .ram-edit .led:not(.on) { box-shadow: inset 0 0 0 1px var(--dim); } /* touch: a bit is too small to tap, so the row is the target, tall enough for a finger, and opens the row editor */ .board.is-touch .ram-row { min-height: 24px; cursor: pointer; } /* and the clock slider tall enough to tap too */ @media (pointer: coarse) { .sim-bar input[type="range"] { height: 32px; } } /* the row editor: the byte's eight bits as buttons big enough to tap, over the board under the row it edits (board.js places it) */ .ram-edit { position: absolute; left: 0; right: 0; z-index: 1; border-color: var(--dim); box-shadow: 0 8px 24px rgb(0 0 0 / 0.3); } .ram-edit .mod-head { align-items: center; } .ram-edit .mod-name { margin-right: 0; } .ram-edit .btn { margin-left: auto; } .ram-edit-bits { display: flex; gap: 4px; } .ram-edit-bit { --led: 10px; display: flex; flex: 1 1 0; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-width: 0; min-height: 40px; padding: 0; border: 1px solid var(--rule); background: none; color: var(--dim); } /* the nibbles apart, as on the instruction register */ .ram-edit-bit:nth-child(5) { margin-left: 6px; } .ram-edit-bit:active { background: var(--hl); } .ram-edit-bit[aria-pressed="true"] { color: var(--fg); font-weight: 600; } /* the bus: eight lanes down the middle */ .bus { grid-area: bus; display: flex; flex-direction: column; align-items: center; padding: 7px 0 9px; border: 1px solid var(--rule); } .bus .mod-head { margin-bottom: 4px; } .bus-val { margin-bottom: 8px; } .lanes { display: flex; flex: 1; gap: 4px; } .lane { width: 2px; background: var(--led-off); } .lane.on { background: var(--red); box-shadow: 0 0 calc(var(--glow) * 6px) color-mix(in srgb, var(--red) 70%, transparent); } /* output: a 7-segment display */ .seg7 { display: flex; gap: 6px; } .seg7 svg { width: 22px; height: 38px; overflow: visible; } .seg7 path { fill: var(--led-off); } .seg7 path.on { fill: var(--red); filter: drop-shadow(0 0 calc(var(--glow) * 3px) color-mix(in srgb, var(--red) 80%, transparent)); } /* the display is a button that switches between unsigned and signed */ .mod-out .mod-body { width: 100%; padding: 0; border: 0; background: none; text-align: inherit; } /* the microstep counter and the control word */ .cw { display: flex; flex-wrap: wrap; gap: 4px; } .cw-bit { display: flex; flex-direction: column; align-items: center; gap: 3px; /* just wider than a three-letter line, so eight fit across the narrow board */ width: 3.2ch; color: var(--dim); font-size: 11px; } .cw-bit.on { color: var(--fg); font-weight: 600; } /* what the step does, kept to two lines so the board doesn't jump as it changes */ .ustep { display: -webkit-box; min-height: 3em; margin: 8px 0 0; overflow: hidden; color: var(--dim); line-height: 1.5; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; } .ustep b { color: var(--fg); font-weight: 600; } /* on a phone the pairs stack */ @container demo (max-width: 440px) { .mod-pair { grid-template-columns: minmax(0, 1fr); } } /* narrow: beside a project's text, or on a phone */ @container demo (max-width: 600px) { .board { --led: 8px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "bus bus" "left right"; /* no text under 11px, with lines a little tighter so the board keeps the height it had at 10.5px */ font-size: 11px; line-height: 1.5; } .bus { flex-direction: row; gap: 1.5ch; padding: 6px 10px; } .bus .mod-head, .bus-val { margin: 0; } .lanes { flex-direction: column; justify-content: center; height: 26px; gap: 1px; } .lane { width: auto; height: 2px; } .mod { padding: 6px 8px 8px; } /* the sixteen rows packed tighter, so RAM's column is no taller than the other one */ .ram-rows { gap: 0; } .ram-row { --led: 6px; grid-template-columns: 1.5ch 2ch auto; line-height: 12px; } .ram-row .dis { display: none; } .seg7 svg { width: 16px; height: 28px; } }