-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MOBILE-4459 storybook: Create storybook for new sites-list component
- Loading branch information
Showing
19 changed files
with
364 additions
and
18 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,32 @@ | ||
// (C) Copyright 2015 Moodle Pty Ltd. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import { CoreSiteFixture } from '@/storybook/stubs/classes/site'; | ||
|
||
export const companyLisaSite: CoreSiteFixture = { | ||
id: 'companylisasite', | ||
info: { | ||
version: '2022041900', | ||
sitename: 'Company', | ||
username: 'lisa', | ||
firstname: 'Lisa', | ||
lastname: 'Díaz', | ||
fullname: 'Lisa Díaz', | ||
lang: 'en', | ||
userid: 1, | ||
siteurl: 'https://company.example.edu', | ||
userpictureurl: 'assets/storybook/avatars/lisa.jpeg', | ||
functions: [], | ||
}, | ||
}; |
This file was deleted.
Oops, something went wrong.
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,32 @@ | ||
// (C) Copyright 2015 Moodle Pty Ltd. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import { CoreSiteFixture } from '@/storybook/stubs/classes/site'; | ||
|
||
export const schoolBarbaraSite: CoreSiteFixture = { | ||
id: 'schoolbarbarasite', | ||
info: { | ||
version: '2022041900', | ||
sitename: 'School', | ||
username: 'barbara', | ||
firstname: 'Barbara', | ||
lastname: 'Gardner', | ||
fullname: 'Barbara Gardner', | ||
lang: 'en', | ||
userid: 1, | ||
siteurl: 'https://campus.example.edu', | ||
userpictureurl: 'assets/storybook/avatars/barbara.png', | ||
functions: [], | ||
}, | ||
}; |
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,32 @@ | ||
// (C) Copyright 2015 Moodle Pty Ltd. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import { CoreSiteFixture } from '@/storybook/stubs/classes/site'; | ||
|
||
export const schoolJefferySite: CoreSiteFixture = { | ||
id: 'schooljefferysite', | ||
info: { | ||
version: '2022041900', | ||
sitename: 'School', | ||
username: 'jeffery', | ||
firstname: 'Jeffery', | ||
lastname: 'Sanders', | ||
fullname: 'Jeffery Sanders', | ||
lang: 'en', | ||
userid: 2, | ||
siteurl: 'https://campus.example.edu', | ||
userpictureurl: 'assets/storybook/avatars/jeffery.png', | ||
functions: [], | ||
}, | ||
}; |
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
23 changes: 23 additions & 0 deletions
23
src/core/components/stories/components/site-list-page/site-list-wrapper.html
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,23 @@ | ||
<ion-app> | ||
<ion-content class="limited-width"> | ||
<core-site-list *ngIf="accountsList" [accountsList]="accountsList" [sitesClickable]="sitesClickable" | ||
[currentSiteClickable]="currentSiteClickable" (onSiteClicked)="siteClicked($event)"> | ||
|
||
<ng-template *ngIf="extraText !== 'none'" #siteLabel let-site="site"> | ||
<p *ngIf="extraText === 'text'">Extra text for user {{ site.fullname }}</p> | ||
<ion-badge *ngIf="extraText === 'badge'" color="light">{{ site.badge }} MB</ion-badge> | ||
</ng-template> | ||
|
||
<ng-template #siteItem let-site="site"> | ||
<ion-button *ngIf="extraDetails === 'delete-button'" fill="clear" color="danger" slot="end"> | ||
<ion-icon name="fas-trash" slot="icon-only"></ion-icon> | ||
</ion-button> | ||
|
||
<ion-badge *ngIf="extraDetails === 'badge'" slot="end"> | ||
<span>{{site.badge}}</span> | ||
</ion-badge> | ||
</ng-template> | ||
|
||
</core-site-list> | ||
</ion-content> | ||
</ion-app> |
60 changes: 60 additions & 0 deletions
60
src/core/components/stories/components/site-list-page/site-list-wrapper.ts
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,60 @@ | ||
// (C) Copyright 2015 Moodle Pty Ltd. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'; | ||
import { CoreAccountsList, CoreLoginHelper } from '@features/login/services/login-helper'; | ||
import { CoreSiteBasicInfo } from '@services/sites'; | ||
|
||
@Component({ | ||
selector: 'core-site-list-wrapper', | ||
templateUrl: 'site-list-wrapper.html', | ||
}) | ||
export class CoreSiteListWrapperComponent implements OnInit, OnChanges { | ||
|
||
@Input() sitesClickable = false; | ||
@Input() currentSiteClickableSelect = 'undefined'; | ||
@Input() extraText: 'text' | 'badge' | 'none' = 'none'; | ||
@Input() extraDetails: 'delete-button' | 'badge' | 'none' = 'none'; | ||
|
||
accountsList?: CoreAccountsList; | ||
currentSiteClickable?: boolean; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
async ngOnInit(): Promise<void> { | ||
this.accountsList = await CoreLoginHelper.getAccountsList(); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
async ngOnChanges(changes: SimpleChanges): Promise<void> { | ||
if (changes.currentSiteClickableSelect) { | ||
this.currentSiteClickable = this.currentSiteClickableSelect === 'undefined' ? | ||
undefined : | ||
this.currentSiteClickableSelect === 'true'; | ||
} | ||
} | ||
|
||
/** | ||
* Site clicked. | ||
* | ||
* @param site Site. | ||
*/ | ||
siteClicked(site: CoreSiteBasicInfo): void { | ||
alert(`clicked on ${site.id} - ${site.fullname}`); | ||
} | ||
|
||
} |
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,78 @@ | ||
// (C) Copyright 2015 Moodle Pty Ltd. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import { Meta, moduleMetadata } from '@storybook/angular'; | ||
|
||
import { story } from '@/storybook/utils/helpers'; | ||
import { CoreSiteListComponent } from '@components/site-list/site-list'; | ||
import { CoreSiteListWrapperComponent } from './components/site-list-page/site-list-wrapper'; | ||
import { CoreComponentsStorybookModule } from './components/components.module'; | ||
|
||
interface Args { | ||
sitesClickable: boolean; | ||
currentSiteClickable: 'true' | 'false' | 'undefined'; | ||
extraText: 'text' | 'badge' | 'none'; | ||
extraDetails: 'delete-button' | 'badge' | 'none'; | ||
} | ||
|
||
export default <Meta<Args>> { | ||
title: 'Core/Site List', | ||
component: CoreSiteListComponent, | ||
decorators: [ | ||
moduleMetadata({ imports: [CoreComponentsStorybookModule] }), | ||
], | ||
argTypes: { | ||
sitesClickable: { | ||
control: { | ||
type: 'boolean', | ||
}, | ||
}, | ||
currentSiteClickable: { | ||
control: { | ||
type: 'select', | ||
options: ['true', 'false', 'undefined'], | ||
}, | ||
}, | ||
extraText: { | ||
control: { | ||
type: 'select', | ||
options: ['text', 'badge', 'none'], | ||
}, | ||
}, | ||
extraDetails: { | ||
control: { | ||
type: 'select', | ||
options: ['delete-button', 'badge', 'none'], | ||
}, | ||
}, | ||
}, | ||
args: { | ||
sitesClickable: false, | ||
currentSiteClickable: 'undefined', | ||
extraText: 'none', | ||
extraDetails: 'none', | ||
}, | ||
}; | ||
|
||
const Template = story<Args>(({ sitesClickable, currentSiteClickable, extraText, extraDetails }) => ({ | ||
component: CoreSiteListWrapperComponent, | ||
props: { | ||
sitesClickable, | ||
currentSiteClickableSelect: currentSiteClickable, | ||
extraText, | ||
extraDetails, | ||
}, | ||
})); | ||
|
||
export const Primary = story<Args>(Template); |
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
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
Oops, something went wrong.