Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | import { Component } from '@angular/core'; import { Input, HostBinding } from '@angular/core'; /** * A versatile panel component with sections for header, content, and footer. * * This component is designed to structure content into a panel layout, supporting configurable size and border visibility. * The `upp-panel` serves as the container, while the `upp-panel-header`, `upp-panel-content`, and `upp-panel-footer` * components define distinct regions within the panel. * * ### Features * - Configurable panel size (`small` or `large`). * - Option to show or hide the border. * - Fully customizable content using Angular's `ng-content` for dynamic projection. * * ### Usage * ```html * <upp-panel size="large" border="show"> * <upp-panel-header> * <h1>Panel Header</h1> * </upp-panel-header> * <upp-panel-content> * <p>Main content goes here.</p> * </upp-panel-content> * <upp-panel-footer> * <button>Submit</button> * </upp-panel-footer> * </upp-panel> * ``` * * ### Options * - **Size (`size`)**: * - `'small'`: Displays the panel with a smaller layout. * - `'large'` (default): Displays the panel with a larger layout. * - **Border (`border`)**: * - `'show'` (default): Displays a visible border around the panel. * - `'hide'`: Hides the panel border. */ @Component({ selector: 'upp-panel', templateUrl: './upp-panel.html', styleUrls: ['./upp-panel.scss'], }) export class UppPanelComponent { /** * Sets the size of the panel. Available options: * - `'small'`: A smaller panel size. * - `'large'`: A larger panel size (default). * * @default 'large' */ @Input() size: 'small' | 'large' | 'auto' = 'large'; /** * Controls whether the panel border is visible. Available options: * - `'show'`: The border is visible (default). * - `'hide'`: The border is hidden. * * @default 'show' */ @Input() lines: 'show' | 'hide' = 'hide'; /** * Dynamically calculates the CSS classes for the panel based on the `size` and `border` inputs. * * @returns A string representing the classes to apply to the panel. */ @HostBinding('class') get panelClasses(): string { const sizeClass = `--${this.size}`; const borderClass = `--border-${this.lines}`; return `${sizeClass} ${borderClass}`.trim(); } } /** * Represents the header section of the `upp-panel` component. * * Use this component to define the content for the panel header. * * @example * ```html * <upp-panel-header> * <h1>Panel Header</h1> * </upp-panel-header> * ``` */ @Component({ selector: 'upp-panel-header', template: `<ng-content></ng-content>`, styleUrls: [], }) export class UppPanelHeaderComponent { // nothing to do } /** * Represents the content section of the `upp-panel` component. * * Use this component to define the main content of the panel. * * @example * ```html * <upp-panel-content> * <p>This is the main content of the panel.</p> * </upp-panel-content> * ``` */ @Component({ selector: 'upp-panel-content', template: ` <div style="height: 100%; width: 100%"> <ng-content></ng-content> </div> `, styleUrls: [], }) export class UppPanelContentComponent { // nothing to do } /** * Represents the footer section of the `upp-panel` component. * * Use this component to define content for the panel footer, such as buttons or links. * * @example * ```html * <upp-panel-footer> * <button>Submit</button> * </upp-panel-footer> * ``` */ @Component({ selector: 'upp-panel-footer', template: `<ng-content></ng-content>`, styleUrls: [], }) export class UppPanelFooterComponent { // nothing to do } |