1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-14 10:26:19 +01:00

[CL-305] Allow margin to be disabled for elements at the bottom of a page (#10132)

This commit is contained in:
Victoria League 2024-07-24 12:08:33 -04:00 committed by GitHub
parent c52709e6f0
commit 5a2db79235
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 67 additions and 26 deletions

View File

@ -13,6 +13,7 @@ import {
ItemModule, ItemModule,
NoItemsModule, NoItemsModule,
SearchModule, SearchModule,
SectionComponent,
} from "@bitwarden/components"; } from "@bitwarden/components";
import { PopupFooterComponent } from "./popup-footer.component"; import { PopupFooterComponent } from "./popup-footer.component";
@ -34,6 +35,7 @@ class ExtensionContainerComponent {}
@Component({ @Component({
selector: "vault-placeholder", selector: "vault-placeholder",
template: ` template: `
<bit-section disableMargin>
<bit-item-group aria-label="Mock Vault Items"> <bit-item-group aria-label="Mock Vault Items">
<bit-item *ngFor="let item of data; index as i"> <bit-item *ngFor="let item of data; index as i">
<button bit-item-content> <button bit-item-content>
@ -50,14 +52,19 @@ class ExtensionContainerComponent {}
<button type="button" bitIconButton="bwi-clone" aria-label="Copy item"></button> <button type="button" bitIconButton="bwi-clone" aria-label="Copy item"></button>
</bit-item-action> </bit-item-action>
<bit-item-action> <bit-item-action>
<button type="button" bitIconButton="bwi-ellipsis-v" aria-label="More options"></button> <button
type="button"
bitIconButton="bwi-ellipsis-v"
aria-label="More options"
></button>
</bit-item-action> </bit-item-action>
</ng-container> </ng-container>
</bit-item> </bit-item>
</bit-item-group> </bit-item-group>
</bit-section>
`, `,
standalone: true, standalone: true,
imports: [CommonModule, ItemModule, BadgeModule, IconButtonModule], imports: [CommonModule, ItemModule, BadgeModule, IconButtonModule, SectionComponent],
}) })
class VaultComponent { class VaultComponent {
protected data = Array.from(Array(20).keys()); protected data = Array.from(Array(20).keys());

View File

@ -1,4 +1,4 @@
<bit-section *ngIf="ciphers?.length > 0 || description"> <bit-section *ngIf="ciphers?.length > 0 || description" [disableMargin]="disableSectionMargin">
<bit-section-header> <bit-section-header>
<h2 bitTypography="h6"> <h2 bitTypography="h6">
{{ title }} {{ title }}

View File

@ -78,6 +78,13 @@ export class VaultListItemsContainerComponent {
@Input({ transform: booleanAttribute }) @Input({ transform: booleanAttribute })
showAutofillButton: boolean; showAutofillButton: boolean;
/**
* Remove the bottom margin from the bit-section in this component
* (used for containers at the end of the page where bottom margin is not needed)
*/
@Input({ transform: booleanAttribute })
disableSectionMargin: boolean = false;
/** /**
* The tooltip text for the organization icon for ciphers that belong to an organization. * The tooltip text for the organization icon for ciphers that belong to an organization.
* @param cipher * @param cipher

View File

@ -65,6 +65,7 @@
[title]="'allItems' | i18n" [title]="'allItems' | i18n"
[ciphers]="remainingCiphers$ | async" [ciphers]="remainingCiphers$ | async"
id="allItems" id="allItems"
disableSectionMargin
></app-vault-list-items-container> ></app-vault-list-items-container>
</ng-container> </ng-container>
</ng-container> </ng-container>

View File

@ -1,14 +1,21 @@
import { coerceBooleanProperty } from "@angular/cdk/coercion";
import { CommonModule } from "@angular/common"; import { CommonModule } from "@angular/common";
import { Component } from "@angular/core"; import { Component, Input } from "@angular/core";
@Component({ @Component({
selector: "bit-section", selector: "bit-section",
standalone: true, standalone: true,
imports: [CommonModule], imports: [CommonModule],
template: ` template: `
<section class="tw-mb-6 md:tw-mb-12"> <section
[ngClass]="{
'tw-mb-6 md:tw-mb-12': !disableMargin
}"
>
<ng-content></ng-content> <ng-content></ng-content>
</section> </section>
`, `,
}) })
export class SectionComponent {} export class SectionComponent {
@Input({ transform: coerceBooleanProperty }) disableMargin = false;
}

View File

@ -13,6 +13,19 @@ import { SectionComponent, SectionHeaderComponent } from "@bitwarden/components"
Sections are simple containers that apply a responsive bottom margin and utilize the semantic Sections are simple containers that apply a responsive bottom margin and utilize the semantic
`section` HTML element. `section` HTML element.
```html
<bit-section>
<div>Lots of amazing content!</div>
</bit-section>
```
To remove the bottom margin (for example, if the section is the last item on the page), you can pass
the `disableMargin` input.
```html
<bit-section disableMargin></bit-section>
```
<Canvas> <Canvas>
<Story of={stories.Default} /> <Story of={stories.Default} />
</Canvas> </Canvas>
@ -24,7 +37,7 @@ Sections often contain a heading. Use `bit-section-header` inside of the `bit-se
```html ```html
<bit-section> <bit-section>
<bit-section-header> <bit-section-header>
<h1 bitTypography="h1">I'm a section header</h2> <h1 bitTypography="h1">I'm a section header</h1>
</bit-section-header> </bit-section-header>
<div>Section content here!</div> <div>Section content here!</div>
</bit-section> </bit-section>

View File

@ -41,6 +41,12 @@ export const Default: Story = {
</bit-section-header> </bit-section-header>
<p bitTypography="body1">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras vitae congue risus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nunc elementum odio nibh, eget pellentesque sem ornare vitae. Etiam vel ante et velit fringilla egestas a sed sem. Fusce molestie nisl et nisi accumsan dapibus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Sed eu risus ex. </p> <p bitTypography="body1">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras vitae congue risus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nunc elementum odio nibh, eget pellentesque sem ornare vitae. Etiam vel ante et velit fringilla egestas a sed sem. Fusce molestie nisl et nisi accumsan dapibus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Sed eu risus ex. </p>
</bit-section> </bit-section>
<bit-section disableMargin>
<bit-section-header>
<h2 bitTypography="h2">Baz</h2>
</bit-section-header>
<p bitTypography="body1">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras vitae congue risus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nunc elementum odio nibh, eget pellentesque sem ornare vitae. Etiam vel ante et velit fringilla egestas a sed sem. Fusce molestie nisl et nisi accumsan dapibus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Sed eu risus ex. </p>
</bit-section>
`, `,
}), }),
}; };