Flip the Bio Card Right to Left

Ama has news for the spring issue. The Lantern Press has accepted its first poem written in Arabic. The poet will get a bio card like those for other featured poets. Arabic reads from right to left. Before that card exists, Teo wants to know whether the card design is ready for it.

In this lesson, you’ll add the poet bio card, flip it to right to left, and see which parts of it stay stuck on the wrong side. You’ll be able to predict where a logical property puts a border or padding and convert a component so it flips by itself. Start by building the card the way you’d write any component today.

Add the Poet Bio Card

Each issue features one poet, and the bio card introduces them with a few lines about their life and a pull quote from their poem. Add this section to index.html, between the contents section and the covers:

Language: HTML
    <section aria-labelledby="poet-heading">
      <h2 id="poet-heading">Featured Poet</h2>
      <article class="bio-card">
        <h3>Inés Duarte</h3>
        <p>Inés writes short poems about weather and the small hours.
          She teaches piano in Porto and has sent a poem to every
          issue.</p>
        <figure class="pull-quote">
          <blockquote>
            <p>The lantern swings, and the street remembers its shape.</p>
          </blockquote>
          <figcaption>From “Lantern Weather”</figcaption>
        </figure>
      </article>
    </section>

The card needs three sizes the zine’s tokens don’t have yet: a comfortable line length and two border widths. Following the tiers you set up, the raw values start as primitives and get semantic tokens that name their roles. Add the primitives below --font-serif in the :root rule of the base layer:

Language: CSS
    --border-1: 1px;
    --border-4: 4px;
    --measure-36: 36rem;

Then add their roles at the end of the semantic tokens:

Language: CSS
    --border-width-frame: var(--border-1);
    --border-width-accent: var(--border-4);
    --size-measure: var(--measure-36);

--size-measure is the longest a line of reading text should get, --border-width-frame is the thin outline around a box, and --border-width-accent is the heavier line that marks something out. The card is a component, so its rules read those roles and go in the cards layer. Add these two rules at the end of the @layer cards block in styles.css:

Language: CSS
    .bio-card {
      max-width: var(--size-measure);
      margin-bottom: var(--space-stack);
      padding: var(--space-inset);
      border: var(--border-width-frame) solid var(--color-text);
    }

    .pull-quote {
      margin: var(--space-gap) 0 0;
      padding-left: var(--space-gap);
      border-left: var(--border-width-accent) solid var(--color-accent);
    }

The card gets a thin frame and stays narrow enough to read comfortably. The pull quote gets the brick-red line down its left side that Teo planned when the tokens arrived, and a little padding keeps the line off the words. Two more rules finish the quote:

Language: CSS
    .pull-quote blockquote {
      margin: 0;
      font-style: italic;
    }

    .pull-quote figcaption {
      text-align: right;
    }

The quote turns italic, and the line that names its poem sits at the right, under the end of the quote. Save, and scroll to the card:

The bio card for Inés Duarte, with a brick red line down the left of the italic pull quote and the poem's name aligned to the right below it.
The Bio Card in a Left-to-Right Page

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Become a Member to join the conversation.