Skip to content

Explore responsive account settings #10121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{{ "changeEmailTwoFactorWarning" | i18n }}
</bit-callout>

<div class="tw-w-1/2 tw-pr-2" formGroupName="step1">
<div class="@md:tw-w-1/2 @md:tw-pr-2" formGroupName="step1">
<bit-form-field>
<bit-label>{{ "masterPass" | i18n }}</bit-label>
<input
Expand Down Expand Up @@ -31,7 +31,7 @@
<p>{{ "changeEmailDesc" | i18n: formGroup.controls.step1.value.newEmail }}</p>
<bit-callout type="warning">{{ "loggedOutWarning" | i18n }}</bit-callout>

<div class="tw-w-1/2 tw-pr-2">
<div class="@md:tw-w-1/2 @md:tw-pr-2">
<bit-form-field>
<bit-label>{{ "code" | i18n }}</bit-label>
<input id="change-email_input_token" bitInput type="text" formControlName="token" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ <h1 bitTypography="h1" class="tw-mt-16 tw-pb-2.5 !tw-text-danger">{{ "dangerZone
<div class="tw-rounded tw-border tw-border-solid tw-border-danger-600 tw-p-5">
<p>{{ "dangerZoneDesc" | i18n }}</p>

<div class="tw-flex tw-flex-row tw-gap-2">
<div class="tw-flex tw-gap-2 tw-flex-wrap">
<ng-content></ng-content>
</div>
</div>
11 changes: 7 additions & 4 deletions apps/web/src/app/auth/settings/account/profile.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<span class="tw-sr-only">{{ "loading" | i18n }}</span>
</div>
<form *ngIf="profile && !loading" [formGroup]="formGroup" [bitSubmit]="submit">
<div class="tw-grid tw-grid-cols-12 tw-gap-6">
<div class="tw-col-span-6">
<div class="tw-grid @md:tw-grid-cols-2 tw-gap-6">
<div>
<bit-form-field>
<bit-label>{{ "name" | i18n }}</bit-label>
<input bitInput formControlName="name" />
Expand All @@ -17,8 +17,12 @@
<bit-label>{{ "email" | i18n }}</bit-label>
<input bitInput formControlName="email" readonly />
</bit-form-field>

<button bitButton bitFormButton type="submit" buttonType="primary">
{{ "save" | i18n }}
</button>
</div>
<div class="tw-col-span-6">
<div>
<div class="tw-mb-3 tw-flex tw-align-middle tw-items-center">
<dynamic-avatar text="{{ profile | userName }}" [id]="profile.id" size="large">
</dynamic-avatar>
Expand All @@ -43,5 +47,4 @@
</app-account-fingerprint>
</div>
</div>
<button bitButton bitFormButton type="submit" buttonType="primary">{{ "save" | i18n }}</button>
</form>
8 changes: 5 additions & 3 deletions apps/web/src/app/layouts/toggle-width.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { NavigationModule } from "@bitwarden/components";

const className = "tw-fixed-width";

@Component({
selector: "app-toggle-width",
template: `<bit-nav-item
Expand All @@ -23,10 +25,10 @@
}

protected toggleWidth() {
if (document.body.style.minWidth === "unset") {
document.body.style.minWidth = "";
if (document.documentElement.classList.contains(className)) {
document.documentElement.classList.remove(className);

Check warning on line 29 in apps/web/src/app/layouts/toggle-width.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/layouts/toggle-width.component.ts#L29

Added line #L29 was not covered by tests
} else {
document.body.style.minWidth = "unset";
document.documentElement.classList.add(className);

Check warning on line 31 in apps/web/src/app/layouts/toggle-width.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/layouts/toggle-width.component.ts#L31

Added line #L31 was not covered by tests
}
}
}
2 changes: 1 addition & 1 deletion apps/web/src/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
๏ปฟ<!doctype html>
<html class="theme_light">
<html class="theme_light tw-fixed-width">

Check failure on line 2 in apps/web/src/index.html

View workflow job for this annotation

GitHub Actions / Lint

Classname 'tw-fixed-width' is not a Tailwind CSS class!
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=1010" />
Expand Down
7 changes: 6 additions & 1 deletion apps/web/src/scss/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ html {
}

body {
min-width: 1010px;
position: relative;

&.layout_frontend {
Expand Down Expand Up @@ -32,6 +31,12 @@ body {
}
}

html.tw-fixed-width {
body {
min-width: 1010px;
}
}

.container {
margin: 0 auto;
max-width: none !important;
Expand Down
69 changes: 69 additions & 0 deletions libs/components/tailwind.config.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,75 @@ module.exports = {
},
},
plugins: [
/**
* Custom plugin for media queries, which uses a `@` prefix. If the html has the
* class `tw-fixed-width` all variants will be applied.
*
* Based on https://github.com/tailwindlabs/tailwindcss-container-queries
* MIT License
*
* Copyright (c) 2023 Tailwind Labs
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
plugin(function ({ matchVariant, theme }) {
// Responsive
const values = theme("screens") ?? {};

matchVariant(
"@",
(value = "", { modifier }) => {
let parsed = parseFloat(value);

return parsed !== null
? [`@media ${modifier ?? ""} (min-width: ${value})`, "html.fixed-width &"]
: [];
},
{
values,
sort(aVariant, zVariant) {
let a = parseFloat(aVariant.value);
let z = parseFloat(zVariant.value);

if (a === null || z === null) return 0;

// Sort values themselves regardless of unit
if (a - z !== 0) return a - z;

let aLabel = aVariant.modifier ?? "";
let zLabel = zVariant.modifier ?? "";

// Explicitly move empty labels to the end
if (aLabel === "" && zLabel !== "") {
return 1;
} else if (aLabel !== "" && zLabel === "") {
return -1;
}

// Sort labels alphabetically in the English locale
// We are intentionally overriding the locale because we do not want the sort to
// be affected by the machine's locale (be it a developer or CI environment)
return aLabel.localeCompare(zLabel, "en", { numeric: true });
},
},
);
}),
plugin(function ({ matchUtilities, theme, addUtilities, addComponents, e, config }) {
matchUtilities(
{
Expand Down
Loading