-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(pix-table): rewrite to block params API
Co-authored-by: Iris Benoit-Martin <[email protected]> Co-authored-by: Jérémie Jadé <[email protected]> Co-authored-by: Fael Bassetti <[email protected]>
- Loading branch information
1 parent
43186c1
commit 49c3f10
Showing
11 changed files
with
243 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{{#if @context.isHeader}} | ||
<th scope="col"> | ||
{{yield to="header"}} | ||
{{@name}} | ||
</th> | ||
{{else}} | ||
<td> | ||
{{#if (has-block "cell")}} | ||
{{yield this.value @context.row to="cell"}} | ||
{{else}} | ||
{{this.value}} | ||
{{/if}} | ||
</td> | ||
{{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Component from '@glimmer/component'; | ||
|
||
export default class PixTableColumn extends Component { | ||
get value() { | ||
if (!this.args.key) return undefined; | ||
return this.args.context.row[this.args.key]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from '@1024pix/pix-ui/components/pix-table-column'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Meta, Story, ArgTypes } from '@storybook/blocks'; | ||
|
||
import * as ComponentStories from './pix-table-column.stories'; | ||
|
||
<Meta of={ComponentStories} /> | ||
|
||
# PixTableColumn | ||
|
||
Une colonne qui s'affiche sous forme de header ou de colonne en enfant d'un [PixTable](/docs/data-display-table--docs) | ||
|
||
<Story of={ComponentStories.Default} height={200} /> | ||
|
||
## Usage | ||
|
||
```html | ||
<PixTableColumn @context={{context}} @name='Description' @key='description'> | ||
``` | ||
|
||
## Arguments | ||
|
||
<ArgTypes /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { hbs } from 'ember-cli-htmlbars'; | ||
|
||
export default { | ||
title: 'Data display/Table/TableColumn', | ||
// TODO: add component attributes information | ||
// select attribute data type from https://storybook.js.org/docs/react/essentials/controls | ||
argTypes: { | ||
context: { | ||
name: 'context', | ||
description: | ||
"Contexte de rendu donné par le composant PixTable parent. Permet de savoir si on doit afficher le header de la colonne ou le contenu d'une cellule.", | ||
type: { name: 'object', required: true }, | ||
}, | ||
}, | ||
}; | ||
|
||
const Template = (args) => { | ||
return { | ||
template: hbs`<PixTableColumn />`, | ||
context: args, | ||
}; | ||
}; | ||
|
||
export const Default = Template.bind({}); | ||
Default.args = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//! template-lint-disable | ||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { render } from '@1024pix/ember-testing-library'; | ||
import { hbs } from 'ember-cli-htmlbars'; | ||
|
||
module('Integration | Component | table-column', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test('it renders the default PixTableColumn', async function (assert) { | ||
// when | ||
await render(hbs`<PixTableColumn />`); | ||
|
||
// then | ||
assert.ok(false); | ||
}); | ||
}); |