|
| 1 | +import {Component} from '@angular/core'; |
| 2 | +import {animate, state, style, transition, trigger} from '@angular/animations'; |
| 3 | + |
| 4 | +/** |
| 5 | + * @title Table with expandable rows |
| 6 | + */ |
| 7 | +@Component({ |
| 8 | + selector: 'table-expandable-rows-example', |
| 9 | + styleUrls: ['table-expandable-rows-example.css'], |
| 10 | + templateUrl: 'table-expandable-rows-example.html', |
| 11 | + animations: [ |
| 12 | + trigger('detailExpand', [ |
| 13 | + state('collapsed', style({height: '0px', minHeight: '0', display: 'none'})), |
| 14 | + state('expanded', style({height: '*'})), |
| 15 | + transition('expanded <=> collapsed', animate('225ms cubic-bezier(0.4, 0.0, 0.2, 1)')), |
| 16 | + ]), |
| 17 | + ], |
| 18 | +}) |
| 19 | +export class TableExpandableRowsExample { |
| 20 | + dataSource = ELEMENT_DATA; |
| 21 | + columnsToDisplay = ['name', 'weight', 'symbol', 'position']; |
| 22 | + expandedElement: PeriodicElement; |
| 23 | +} |
| 24 | + |
| 25 | +export interface PeriodicElement { |
| 26 | + name: string; |
| 27 | + position: number; |
| 28 | + weight: number; |
| 29 | + symbol: string; |
| 30 | + description: string; |
| 31 | +} |
| 32 | + |
| 33 | +const ELEMENT_DATA: PeriodicElement[] = [ |
| 34 | + { |
| 35 | + position: 1, |
| 36 | + name: 'Hydrogen', |
| 37 | + weight: 1.0079, |
| 38 | + symbol: 'H', |
| 39 | + description: `Hydrogen is a chemical element with symbol H and atomic number 1. With a standard |
| 40 | + atomic weight of 1.008, hydrogen is the lightest element on the periodic table.` |
| 41 | + }, { |
| 42 | + position: 2, |
| 43 | + name: 'Helium', |
| 44 | + weight: 4.0026, |
| 45 | + symbol: 'He', |
| 46 | + description: `Helium is a chemical element with symbol He and atomic number 2. It is a |
| 47 | + colorless, odorless, tasteless, non-toxic, inert, monatomic gas, the first in the noble gas |
| 48 | + group in the periodic table. Its boiling point is the lowest among all the elements.` |
| 49 | + }, { |
| 50 | + position: 3, |
| 51 | + name: 'Lithium', |
| 52 | + weight: 6.941, |
| 53 | + symbol: 'Li', |
| 54 | + description: `Lithium is a chemical element with symbol Li and atomic number 3. It is a soft, |
| 55 | + silvery-white alkali metal. Under standard conditions, it is the lightest metal and the |
| 56 | + lightest solid element.` |
| 57 | + }, { |
| 58 | + position: 4, |
| 59 | + name: 'Beryllium', |
| 60 | + weight: 9.0122, |
| 61 | + symbol: 'Be', |
| 62 | + description: `Beryllium is a chemical element with symbol Be and atomic number 4. It is a |
| 63 | + relatively rare element in the universe, usually occurring as a product of the spallation of |
| 64 | + larger atomic nuclei that have collided with cosmic rays.` |
| 65 | + }, { |
| 66 | + position: 5, |
| 67 | + name: 'Boron', |
| 68 | + weight: 10.811, |
| 69 | + symbol: 'B', |
| 70 | + description: `Boron is a chemical element with symbol B and atomic number 5. Produced entirely |
| 71 | + by cosmic ray spallation and supernovae and not by stellar nucleosynthesis, it is a |
| 72 | + low-abundance element in the Solar system and in the Earth's crust.` |
| 73 | + }, { |
| 74 | + position: 6, |
| 75 | + name: 'Carbon', |
| 76 | + weight: 12.0107, |
| 77 | + symbol: 'C', |
| 78 | + description: `Carbon is a chemical element with symbol C and atomic number 6. It is nonmetallic |
| 79 | + and tetravalent—making four electrons available to form covalent chemical bonds. It belongs |
| 80 | + to group 14 of the periodic table.` |
| 81 | + }, { |
| 82 | + position: 7, |
| 83 | + name: 'Nitrogen', |
| 84 | + weight: 14.0067, |
| 85 | + symbol: 'N', |
| 86 | + description: `Nitrogen is a chemical element with symbol N and atomic number 7. It was first |
| 87 | + discovered and isolated by Scottish physician Daniel Rutherford in 1772.` |
| 88 | + }, { |
| 89 | + position: 8, |
| 90 | + name: 'Oxygen', |
| 91 | + weight: 15.9994, |
| 92 | + symbol: 'O', |
| 93 | + description: `Oxygen is a chemical element with symbol O and atomic number 8. It is a member of |
| 94 | + the chalcogen group on the periodic table, a highly reactive nonmetal, and an oxidizing |
| 95 | + agent that readily forms oxides with most elements as well as with other compounds.` |
| 96 | + }, { |
| 97 | + position: 9, |
| 98 | + name: 'Fluorine', |
| 99 | + weight: 18.9984, |
| 100 | + symbol: 'F', |
| 101 | + description: `Fluorine is a chemical element with symbol F and atomic number 9. It is the |
| 102 | + lightest halogen and exists as a highly toxic pale yellow diatomic gas at standard |
| 103 | + conditions.` |
| 104 | + }, { |
| 105 | + position: 10, |
| 106 | + name: 'Neon', |
| 107 | + weight: 20.1797, |
| 108 | + symbol: 'Ne', |
| 109 | + description: `Neon is a chemical element with symbol Ne and atomic number 10. It is a noble gas. |
| 110 | + Neon is a colorless, odorless, inert monatomic gas under standard conditions, with about |
| 111 | + two-thirds the density of air.` |
| 112 | + }, |
| 113 | +]; |
0 commit comments