This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 828
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Live location sharing: maximised view sidebar container (#8360)
* add h4 Signed-off-by: Kerry Archibald <kerrya@element.io> * add mixin to clear list style Signed-off-by: Kerry Archibald <kerrya@element.io> * add basic sidebar container Signed-off-by: Kerry Archibald <kerrya@element.io> * open list view button on beaconviewdialog Signed-off-by: Kerry Archibald <kerrya@element.io> * update tests for new utils Signed-off-by: Kerry Archibald <kerrya@element.io>
- Loading branch information
Kerry
authored
Apr 20, 2022
1 parent
a471742
commit e45cd39
Showing
14 changed files
with
307 additions
and
3 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 |
---|---|---|
|
@@ -692,3 +692,9 @@ legend { | |
} | ||
} | ||
} | ||
|
||
@define-mixin ListResetDefault { | ||
list-style: none; | ||
padding: 0; | ||
margin: 0; | ||
} |
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,57 @@ | ||
/* | ||
Copyright 2022 The Matrix.org Foundation C.I.C. | ||
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. | ||
*/ | ||
|
||
.mx_DialogSidebar { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
height: 100%; | ||
width: 265px; | ||
|
||
box-sizing: border-box; | ||
padding: $spacing-16; | ||
|
||
background-color: $background; | ||
box-shadow: 0px 4px 4px $menu-box-shadow-color; | ||
} | ||
|
||
.mx_DialogSidebar_header { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
justify-content: space-between; | ||
|
||
flex: 0; | ||
margin-bottom: $spacing-16; | ||
|
||
color: $primary-content; | ||
} | ||
|
||
.mx_DialogSidebar_closeButton { | ||
@mixin ButtonResetDefault; | ||
} | ||
|
||
.mx_DialogSidebar_closeButtonIcon { | ||
color: $tertiary-content; | ||
height: 12px; | ||
} | ||
|
||
.mx_DialogSidebar_list { | ||
@mixin ListResetDefault; | ||
flex: 1 1 0; | ||
width: 100%; | ||
overflow: auto; | ||
} |
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,50 @@ | ||
/* | ||
Copyright 2022 The Matrix.org Foundation C.I.C. | ||
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 React from 'react'; | ||
import { Beacon } from 'matrix-js-sdk/src/matrix'; | ||
|
||
import { Icon as CloseIcon } from '../../../../res/img/image-view/close.svg'; | ||
import { _t } from '../../../languageHandler'; | ||
import AccessibleButton from '../elements/AccessibleButton'; | ||
import Heading from '../typography/Heading'; | ||
|
||
interface Props { | ||
beacons: Beacon[]; | ||
requestClose: () => void; | ||
} | ||
|
||
const DialogSidebar: React.FC<Props> = ({ beacons, requestClose }) => { | ||
return <div className='mx_DialogSidebar'> | ||
<div className='mx_DialogSidebar_header'> | ||
<Heading size='h4'>{ _t('View List') }</Heading> | ||
<AccessibleButton | ||
className='mx_DialogSidebar_closeButton' | ||
onClick={requestClose} | ||
title={_t('Close sidebar')} | ||
data-test-id='dialog-sidebar-close' | ||
> | ||
<CloseIcon className='mx_DialogSidebar_closeButtonIcon' /> | ||
</AccessibleButton> | ||
</div> | ||
<ol className='mx_DialogSidebar_list'> | ||
{ /* TODO nice elements */ } | ||
{ beacons.map((beacon, index) => <li key={beacon.identifier}>{ index }</li>) } | ||
</ol> | ||
</div>; | ||
}; | ||
|
||
export default DialogSidebar; |
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,47 @@ | ||
/* | ||
Copyright 2022 The Matrix.org Foundation C.I.C. | ||
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 React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import { act } from 'react-dom/test-utils'; | ||
|
||
import DialogSidebar from '../../../../src/components/views/beacon/DialogSidebar'; | ||
import { findByTestId } from '../../../test-utils'; | ||
|
||
describe('<DialogSidebar />', () => { | ||
const defaultProps = { | ||
beacons: [], | ||
requestClose: jest.fn(), | ||
}; | ||
const getComponent = (props = {}) => | ||
mount(<DialogSidebar {...defaultProps} {...props} />); | ||
|
||
it('renders sidebar correctly', () => { | ||
const component = getComponent(); | ||
expect(component).toMatchSnapshot(); | ||
}); | ||
|
||
it('closes on close button click', () => { | ||
const requestClose = jest.fn(); | ||
const component = getComponent({ requestClose }); | ||
|
||
act(() => { | ||
findByTestId(component, 'dialog-sidebar-close').at(0).simulate('click'); | ||
}); | ||
|
||
expect(requestClose).toHaveBeenCalled(); | ||
}); | ||
}); |
53 changes: 53 additions & 0 deletions
53
test/components/views/beacon/__snapshots__/DialogSidebar-test.tsx.snap
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,53 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<DialogSidebar /> renders sidebar correctly 1`] = ` | ||
<DialogSidebar | ||
beacons={Array []} | ||
requestClose={[MockFunction]} | ||
> | ||
<div | ||
className="mx_DialogSidebar" | ||
> | ||
<div | ||
className="mx_DialogSidebar_header" | ||
> | ||
<Heading | ||
size="h4" | ||
> | ||
<h4 | ||
className="mx_Heading_h4" | ||
> | ||
View List | ||
</h4> | ||
</Heading> | ||
<AccessibleButton | ||
className="mx_DialogSidebar_closeButton" | ||
data-test-id="dialog-sidebar-close" | ||
element="div" | ||
onClick={[MockFunction]} | ||
role="button" | ||
tabIndex={0} | ||
title="Close sidebar" | ||
> | ||
<div | ||
className="mx_AccessibleButton mx_DialogSidebar_closeButton" | ||
data-test-id="dialog-sidebar-close" | ||
onClick={[MockFunction]} | ||
onKeyDown={[Function]} | ||
onKeyUp={[Function]} | ||
role="button" | ||
tabIndex={0} | ||
title="Close sidebar" | ||
> | ||
<div | ||
className="mx_DialogSidebar_closeButtonIcon" | ||
/> | ||
</div> | ||
</AccessibleButton> | ||
</div> | ||
<ol | ||
className="mx_DialogSidebar_list" | ||
/> | ||
</div> | ||
</DialogSidebar> | ||
`; |
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.