全屏
<div class="app">
  <h1>Hello I am an app</h1>
  <p>Canary only behind #experimental-web-platform-feature flag. Lorem ipsum dolor sit amet consectetur adipisicing elit. Dicta cupiditate ex, quisquam quaerat hic amet beatae reprehenderit ipsum cumque iure quia debitis nobis ad nisi? Reprehenderit libero ullam odio laudantium.</p>
</div>

<!-- Toolbar -->

<div class="settings-toolbar">
  <h2 class="settings-heading">Settings Toolbar</h2>
  <ul class="settings-list">
    <li class="settings-item">
      <button popovertarget="profile-settings-popover">
        <span aria-hidden="true">👤</span>
        <span class="sr-only">Profile Settings</span>
      </button>
    </li>
    <li class="settings-item">
      <button popovertarget="theme-settings-popover">
        <span aria-hidden="true">🎨</span>
        <span class="sr-only">Appearance Settings</span>
      </button>
    </li>
    <li class="settings-item">
      <button popovertarget="region-settings-popover">
        <span aria-hidden="true">🌎</span>
        <span class="sr-only">Language and Region Settings</span>
      </button>
    </li>
  </ul>
</div>

<!-- Popovers -->

<!-- User Settings -->
<div id="profile-settings-popover" class="settings-popover" popover>
  <button class="close-btn" popovertarget="profile-settings-popover" popovertargetaction="hide">
    <span>❌</span>
    <span class="sr-only">Close</span>
  </button>
  <h2>Profile Settings</h2>
  <form>
    <div class="settings-form-section">
      <label for="name">Update Display Name:</label>
      <input type="text" name="name" value="Joseph Leonardo" />
    </div>
    <div class="settings-form-section">
      <label for="username">Update Username:</label>
      <input type="text" name="username" value="jleo_codes" />
    </div>
    <div class="settings-form-section">
      <label for="email">Update E-mail:</label>
      <input type="email" name="email" value="jleo2023@gmail.com" />
    </div>
    <div class="settings-form-section">
    <fieldset>
      <legend>Preffered method of contact:</legend>
      <input checked type="radio" id="contactChoice1" name="contact" value="email" />
      <label for="contactChoice1">Email</label>
      <input type="radio" id="contactChoice2" name="contact" value="phone" />
      <label for="contactChoice2">Text</label>
      </fieldset>
    </div>
  </form>
</div>

<!-- Theme Settings -->
<div id="theme-settings-popover" class="settings-popover" popover>
  <button class="close-btn" popovertarget="theme-settings-popover" popovertargetaction="hide">
    <span>❌</span>
    <span class="sr-only">Close</span>
  </button>
  <h2>Theme Settings</h2>
    <form>
      <div class="settings-form-section">
        <fieldset class="two-by">
          <div>
            <input type="radio" id="dark" name="theme" value="dark">
            <label for="dark"><span>🌙</span> Dark</label>
          </div>
          <div>
            <input type="radio" checked id="light" name="theme" value="light">
            <label for="light"><span>☀️</span> Light</label>
          </div>
        </fieldset>
      </div>
  </form>
</div>

  <!-- Region Settings -->
<div id="region-settings-popover" class="settings-popover" popover>
  <button class="close-btn" popovertarget="region-settings-popover" popovertargetaction="hide">
    <span>❌</span>
    <span class="sr-only">Close</span>
  </button>
  <h2>Region Settings</h2>
    <form>
      <label for="language">Preffered Language:</label>
      <select name="lang" id="language">
        <option>language</option>
          <option value="AF">Afrikaans</option>
          <option value="SQ">Albanian</option>
          <option value="AR">Arabic</option>
          <option value="HY">Armenian</option>
          <option value="EU">Basque</option>
          <option value="BN">Bengali</option>
          <option value="BG">Bulgarian</option>
          <option value="CA">Catalan</option>
          <option value="KM">Cambodian</option>
          <option value="ZH">Chinese (Mandarin)</option>
          <option value="HR">Croatian</option>
          <option value="CS">Czech</option>
          <option value="DA">Danish</option>
          <option value="NL">Dutch</option>
          <option selected value="EN">English</option>
          <option value="ET">Estonian</option>
          <option value="FJ">Fiji</option>
          <option value="FI">Finnish</option>
          <option value="FR">French</option>
          <option value="KA">Georgian</option>
          <option value="DE">German</option>
          <option value="EL">Greek</option>
          <option value="GU">Gujarati</option>
          <option value="HE">Hebrew</option>
          <option value="HI">Hindi</option>
          <option value="HU">Hungarian</option>
          <option value="IS">Icelandic</option>
          <option value="ID">Indonesian</option>
          <option value="GA">Irish</option>
          <option value="IT">Italian</option>
          <option value="JA">Japanese</option>
          <option value="JW">Javanese</option>
          <option value="KO">Korean</option>
          <option value="LA">Latin</option>
          <option value="LV">Latvian</option>
          <option value="LT">Lithuanian</option>
          <option value="MK">Macedonian</option>
          <option value="MS">Malay</option>
          <option value="ML">Malayalam</option>
          <option value="MT">Maltese</option>
          <option value="MI">Maori</option>
          <option value="MR">Marathi</option>
          <option value="MN">Mongolian</option>
          <option value="NE">Nepali</option>
          <option value="NO">Norwegian</option>
          <option value="FA">Persian</option>
          <option value="PL">Polish</option>
          <option value="PT">Portuguese</option>
          <option value="PA">Punjabi</option>
          <option value="QU">Quechua</option>
          <option value="RO">Romanian</option>
          <option value="RU">Russian</option>
          <option value="SM">Samoan</option>
          <option value="SR">Serbian</option>
          <option value="SK">Slovak</option>
          <option value="SL">Slovenian</option>
          <option value="ES">Spanish</option>
          <option value="SW">Swahili</option>
          <option value="SV">Swedish </option>
          <option value="TA">Tamil</option>
          <option value="TT">Tatar</option>
          <option value="TE">Telugu</option>
          <option value="TH">Thai</option>
          <option value="BO">Tibetan</option>
          <option value="TO">Tonga</option>
          <option value="TR">Turkish</option>
          <option value="UK">Ukrainian</option>
          <option value="UR">Urdu</option>
          <option value="UZ">Uzbek</option>
          <option value="VI">Vietnamese</option>
          <option value="CY">Welsh</option>
          <option value="XH">Xhosa</option>
      </select>
      <label for="timezone-offset">Timezone:</label>
      <select name="timezone_offset" id="timezone-offset">
        <option value="-12:00">(GMT -12:00) Eniwetok, Kwajalein</option>
        <option value="-11:00">(GMT -11:00) Midway Island, Samoa</option>
        <option value="-10:00">(GMT -10:00) Hawaii</option>
        <option value="-09:50">(GMT -9:30) Taiohae</option>
        <option value="-09:00">(GMT -9:00) Alaska</option>
        <option value="-08:00">(GMT -8:00) Pacific Time (US & Canada)</option>
        <option value="-07:00">(GMT -7:00) Mountain Time (US & Canada)</option>
        <option value="-06:00">(GMT -6:00) Central Time (US & Canada), Mexico City</option>
        <option selected value="-05:00">(GMT -5:00) Eastern Time (US & Canada), Bogota, Lima</option>
        <option value="-04:50">(GMT -4:30) Caracas</option>
        <option value="-04:00">(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz</option>
        <option value="-03:50">(GMT -3:30) Newfoundland</option>
        <option value="-03:00">(GMT -3:00) Brazil, Buenos Aires, Georgetown</option>
        <option value="-02:00">(GMT -2:00) Mid-Atlantic</option>
        <option value="-01:00">(GMT -1:00) Azores, Cape Verde Islands</option>
        <option value="+00:00">(GMT) Western Europe Time, London, Lisbon, Casablanca</option>
        <option value="+01:00">(GMT +1:00) Brussels, Copenhagen, Madrid, Paris</option>
        <option value="+02:00">(GMT +2:00) Kaliningrad, South Africa</option>
        <option value="+03:00">(GMT +3:00) Baghdad, Riyadh, Moscow, St. Petersburg</option>
        <option value="+03:50">(GMT +3:30) Tehran</option>
        <option value="+04:00">(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi</option>
        <option value="+04:50">(GMT +4:30) Kabul</option>
        <option value="+05:00">(GMT +5:00) Ekaterinburg, Islamabad, Karachi, Tashkent</option>
        <option value="+05:50">(GMT +5:30) Bombay, Calcutta, Madras, New Delhi</option>
        <option value="+05:75">(GMT +5:45) Kathmandu, Pokhara</option>
        <option value="+06:00">(GMT +6:00) Almaty, Dhaka, Colombo</option>
        <option value="+06:50">(GMT +6:30) Yangon, Mandalay</option>
        <option value="+07:00">(GMT +7:00) Bangkok, Hanoi, Jakarta</option>
        <option value="+08:00">(GMT +8:00) Beijing, Perth, Singapore, Hong Kong</option>
        <option value="+08:75">(GMT +8:45) Eucla</option>
        <option value="+09:00">(GMT +9:00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk</option>
        <option value="+09:50">(GMT +9:30) Adelaide, Darwin</option>
        <option value="+10:00">(GMT +10:00) Eastern Australia, Guam, Vladivostok</option>
        <option value="+10:50">(GMT +10:30) Lord Howe Island</option>
        <option value="+11:00">(GMT +11:00) Magadan, Solomon Islands, New Caledonia</option>
        <option value="+11:50">(GMT +11:30) Norfolk Island</option>
        <option value="+12:00">(GMT +12:00) Auckland, Wellington, Fiji, Kamchatka</option>
        <option value="+12:75">(GMT +12:45) Chatham Islands</option>
        <option value="+13:00">(GMT +13:00) Apia, Nukualofa</option>
        <option value="+14:00">(GMT +14:00) Line Islands, Tokelau</option>
      </select>
    </form>
</div>
.settings-popover {
  &:popover-open {
    /*   0. BEFORE-OPEN STATE   */
    /*  initial state for what we're animating *in* from, 
        in this case: goes from lower (y + 20px) to center  */
    @starting-style {
      transform: translateY(20px);
      opacity: 0;
    }
    
    /*   1. OPEN STATE   */
    /*  state when popover is open, BOTH:
        what we're transitioning *in* to 
        and transitioning *out* from */
    transform: translateY(0);
    opacity: 1;
  }
  
  /*   2. AFTER-OPEN-IS-CLOSED STATE   */
  /*  initial state for what we're animating *out* to , 
      in this case: goes from center to (y - 50px) higher */
  transform: translateY(-50px);
  opacity: 0;
  
  /*  enumarate transitioning properties, including display */
  transition: transform 0.5s, opacity 0.5s, display 0.5s allow-discrete;
}

/* etc. */

.settings-popover {
  background: ghostwhite;
  position: fixed;
  margin: auto;
  border: 1px solid skyblue;
  padding: 2rem;
  line-height: 2;
  width: 350px;
  box-shadow: 0 0 25px dimgray;
}


.settings-popover button {
  background: none;
  border: none;
  filter: grayscale(1);
}

.settings-popover label {
  width: 100%;
  font-weight: 600;
}

.settings-popover input,
.settings-popover select {
  font-size: 1rem;
  padding: 0.25rem 0.5rem;
}

.settings-popover h2 {
  font-size: 1.75rem;
}

.settings-form-section {
  display: grid;
  margin-top: 1rem;
}

.settings-popover::backdrop {
  background: rgb(170 210 220 / 0.5);
}

.settings-toolbar {
  background: aliceblue;
  padding: 0.5rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100vw;
}

.settings-list {
  display: inline-grid;
  gap: 0.5rem;
}

.settings-item {
  grid-row: 1;
}

.settings-list button {
  border-radius: 100%;
  height: 2.5rem;
  aspect-ratio: 1/1;
  font-size: 1.5rem;
  background: #e2f2ff;
  border: 2px solid skyblue;
  line-height: 0;
}

select {
  width: 100%;
}

.app {
  padding: 2rem;
  max-width: 600px;
  margin: 0 auto;
}

.close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
}

h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

body {
  height: 100dvh;
  font-family: system-ui, sans-serif;
  line-height: 1.5;
  display: grid;
  grid-template-rows: 1fr auto;
  justify-content: space-between;
}

* {
  box-sizing: border-box;
}

/* utils */
.sr-only:not(:focus):not(:active) {
  clip: rect(0 0 0 0); 
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap; 
  width: 1px;
}

.two-by {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
返回