2.1.0 • Published 9 months ago

@chill-viking/layout v2.1.0

Weekly downloads
-
License
GPL-3.0-or-later
Repository
github
Last release
9 months ago

@chill-viking/layout

Maintainability Rating Code Smells Coverage Technical Debt Vulnerabilities Bugs Security Rating

This Angular package provides a layout component for your application that keeps its contents contained within the bounds of the web browser. The layout consists of three sections: a header, a footer, and the body of the content. Use it to give your application a consistent and organized look and feel.

Installation

To install this package, run the following command in your terminal:

npm install @chill-viking/layout

Usage

Import

To use this package in your Angular project, import it in your module like so:

import { ChillVikingLayoutModule } from '@chill-viking/layout';

@NgModule({
  imports: [ChillVikingLayoutModule],
})
export class MyModule {}

Template

Then, you can use the cvLayout component in your templates and pass in data for the header and footer using the [data] attribute:

<cv-layout
  [data]="{ header: { title$: title$ }, footer: { copyRightHolder: 'Chill Viking' } }"
>
  <ng-template cvHeader let-header>
    <h1>Custom header for {{ header.title$ | async }}</h1>
  </ng-template>
  <p>My Content</p>
  <ng-template cvFooter let-footer>
    <span>Copyright &copy; 2023 {{ footer.copyRightHolder }}</span>
  </ng-template>
</cv-layout>

All content without a ng-template and a directive will be rendered as the body of the layout. The cvHeader and cvFooter directives are optional and can be omitted if desired.

Object Types

The types used in cvLayout are as follows

export type LayoutHeaderContext = {
  title$: Observable<string>;
};

export type LayoutFooterContext = {
  copyRightHolder?: string;
};

export type LayoutContext = {
  header: LayoutHeaderContext;
  footer?: LayoutFooterContext;
};

The type of the [data] input of cvLayout is LayoutContext.

Injected Templates using Directives

The cvHeader directive should be used in an ng-template element with a let-header attribute, and the cvFooter directive should be used in an ng-template element with a let-footer attribute. The let-header attribute defines the data that will be provided to the template for the header, and the let-footer attribute defines the data that will be provided to the template for the footer.

See object types for details on the data that will be provided to the header and footer templates. The title$ property of the header object should be an Observable of type string that emits the title to display in the header. The copyRightHolder property of the footer object is optional and should be a string that specifies the copyright holder to display in the footer.

Default Header Template

If a template is not provided for the header, the following will be the default used

<h1>{{ header.title$ | async }}</h1>

Default Footer Template

There is no default template for the footer.

Component

Here is an example of how you could set up the data in your component class:

import { Observable } from 'rxjs';

@Component({
  selector: 'my-component',
  templateUrl: './my-component.html',
})
export class MyComponent {
  title$: Observable<string> = of('My Title');
}

You can then bind the title$ property to the cvLayout component using the [data] attribute as shown above.

Defaults

The default for the [data] input of the component is:

{
  header: {
    title$: of('[data] not provided'),
  },
  footer: undefined,
}

The header object is always included in the data input and has a default title$ property of of('[data] not provided') creating a header with [data] not provided. The footer object is optional and has a default value of undefined.

Contributing

We welcome contributions to this package! If you have an idea for a fun feature, feel free to open a pull request, create an issue, or start a discussion.

License

This package is licensed under the GNU General Public License. See the LICENSE file for more details.

3.1.0-alpha.586

9 months ago

3.1.0-alpha.536

11 months ago

3.1.0-alpha.541

11 months ago

3.1.0-alpha.415

1 year ago

3.1.0-alpha.472

12 months ago

3.1.0-alpha.204

1 year ago

3.1.0-alpha.205

1 year ago

3.0.1-alpha.198

1 year ago

2.0.1

1 year ago

3.0.1-alpha.194

1 year ago

3.0.1-alpha.186

1 year ago

2.1.0

1 year ago

3.0.0-alpha.179

1 year ago

3.0.0-alpha.128

1 year ago

3.0.0-alpha.130

1 year ago

3.0.0-alpha.131

1 year ago

3.0.0-alpha.173

1 year ago

3.0.0-alpha.81

1 year ago

3.0.0-alpha.80

1 year ago

3.0.0-alpha.79

1 year ago

3.0.1-alpha.86

1 year ago

3.0.0-alpha.72

1 year ago

3.0.0-alpha.71

1 year ago

3.0.0-alpha.74

1 year ago

3.0.0-alpha.73

1 year ago

3.0.0-alpha.76

1 year ago

3.0.0-alpha.75

1 year ago

3.0.0-alpha.78

1 year ago

3.0.0-alpha.77

1 year ago

3.0.0-alpha.70

1 year ago

3.0.0-alpha.69

1 year ago

3.0.0-alpha.68

1 year ago

3.0.0-alpha.83

1 year ago

3.0.0-alpha.82

1 year ago

3.0.0-alpha.85

1 year ago

3.0.0-alpha.84

1 year ago

3.0.0-alpha.67

1 year ago

3.0.0-alpha.66

1 year ago

3.0.0-alpha.58

1 year ago

1.0.1-alpha.2

1 year ago

3.0.1-alpha.62

1 year ago

1.0.1-alpha.1

1 year ago

3.0.1-alpha.63

1 year ago

2.0.0-alpha.1

1 year ago

3.0.0-alpha.52

1 year ago

3.0.0-alpha.53

1 year ago

3.0.0-alpha.55

1 year ago

2.0.0

1 year ago

3.0.1-alpha.50

1 year ago

3.0.1-alpha.51

1 year ago

3.0.0-alpha.49

1 year ago

3.0.0-alpha.48

1 year ago

3.0.1-alpha.54

1 year ago

3.0.1-alpha.56

1 year ago

3.0.1-alpha.57

1 year ago

3.0.0-alpha.61

1 year ago

3.0.0-alpha.60

1 year ago

3.0.1-alpha.59

1 year ago

1.0.0-alpha

1 year ago

3.0.0-alpha.65

1 year ago

3.0.0-alpha.64

1 year ago

2.0.0-alpha.47

1 year ago

0.0.1-alpha

1 year ago