-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #325 from ProteinsWebTeam/dev
structural model into master
- Loading branch information
Showing
28 changed files
with
4,067 additions
and
1,743 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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 |
---|---|---|
|
@@ -23,3 +23,11 @@ | |
no-repeat 50% 90%; | ||
background-size: 100%; | ||
} | ||
|
||
.dark { | ||
color: white; | ||
& a { | ||
color: skyblue; | ||
font-weight: bold; | ||
} | ||
} |
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
101 changes: 101 additions & 0 deletions
101
src/components/SimpleCommonComponents/PictureInPicturePanel/index.js
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,101 @@ | ||
// @flow | ||
import React, { useState, useEffect, useRef } from 'react'; | ||
import T from 'prop-types'; | ||
|
||
import { intersectionObserver as intersectionObserverPolyfill } from 'utils/polyfills'; | ||
|
||
import { foundationPartial } from 'styles/foundation'; | ||
import style from './style.css'; | ||
import fonts from 'EBI-Icon-fonts/fonts.css'; | ||
|
||
const f = foundationPartial(style, fonts); | ||
|
||
const NUMBER_OF_CHECKS = 10; | ||
const optionsForObserver = { | ||
root: null, | ||
rootMargin: '0px', | ||
/* eslint-disable-next-line prefer-spread */ | ||
threshold: Array.apply(null, { length: NUMBER_OF_CHECKS }).map( | ||
// $FlowFixMe | ||
Number.call, | ||
(n) => (n + 1) / NUMBER_OF_CHECKS, | ||
), | ||
}; | ||
|
||
const PictureInPicturePanel = ({ | ||
className, | ||
testId, | ||
hideBar = false, | ||
OtherControls = null, | ||
OtherButtons = null, | ||
onChangingMode = () => null, | ||
children, | ||
}) => { | ||
const [isStuck, setStuck] = useState(false); | ||
const [isMinimized, setMinimized] = useState(false); | ||
const wrapperRef /*: { current: null | HTMLElement } */ = useRef(null); | ||
let observer = null; | ||
const threshold = 0.4; | ||
useEffect(() => { | ||
const asynLoadPolyfill = async () => await intersectionObserverPolyfill(); | ||
asynLoadPolyfill(); | ||
}, []); | ||
useEffect(() => { | ||
if (wrapperRef?.current) { | ||
observer = new IntersectionObserver((entries) => { | ||
setStuck( | ||
((wrapperRef?.current?.getBoundingClientRect() /*: any */)?.y || 0) < | ||
0 && entries[0].intersectionRatio < threshold, | ||
); | ||
onChangingMode(); | ||
}, optionsForObserver); | ||
observer.observe(wrapperRef.current); | ||
} | ||
return () => { | ||
if (observer) observer.disconnect(); | ||
}; | ||
}, [wrapperRef]); | ||
return ( | ||
<div ref={wrapperRef} className={f('wrapper')}> | ||
<div | ||
className={f(className, 'content', { | ||
'is-stuck': isStuck, | ||
'is-minimized': isMinimized, | ||
})} | ||
data-testid={testId} | ||
> | ||
{children} | ||
<div | ||
className={f('control-bar', { | ||
hide: hideBar, | ||
})} | ||
> | ||
{OtherControls} | ||
<div className={f('controls')}> | ||
{OtherButtons} | ||
{isStuck && ( | ||
<button | ||
data-icon={isMinimized ? '\uF2D0' : '\uF2D1'} | ||
title={'Minimize'} | ||
onClick={() => setMinimized(!isMinimized)} | ||
className={f('control-icon', 'icon', 'icon-common')} | ||
/> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
PictureInPicturePanel.propTypes = { | ||
className: T.string, | ||
testId: T.string, | ||
hideBar: T.bool, | ||
OtherControls: T.any, | ||
OtherButtons: T.any, | ||
onChangingMode: T.func, | ||
children: T.any, | ||
}; | ||
|
||
export default PictureInPicturePanel; |
73 changes: 73 additions & 0 deletions
73
src/components/SimpleCommonComponents/PictureInPicturePanel/style.css
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,73 @@ | ||
@import '../../../styles/timing.css'; | ||
@import '../../../styles/colors.css'; | ||
@import '../../../styles/z-index.css'; | ||
|
||
:root { | ||
--height-viewer: 50vh; | ||
--height-bar: 2.3em; | ||
} | ||
|
||
.wrapper { | ||
height: var(--height-viewer); | ||
width: 100%; | ||
& .content { | ||
position: relative; | ||
display: flex; | ||
flex-direction: column; | ||
height: 100%; | ||
transition: height var(--timing-really-fast) ease-in-out; | ||
} | ||
|
||
& .control-bar { | ||
width: auto; | ||
height: var(--height-bar); | ||
margin-top: calc(0 - var(--height-bar)); | ||
display: flex; | ||
justify-content: space-between; | ||
background: white; | ||
|
||
& .controls { | ||
white-space: nowrap; | ||
overflow: visible; | ||
flex-grow: 1; | ||
display: flex; | ||
justify-content: flex-end; | ||
align-items: center; | ||
& button { | ||
font-size: 1.5em; | ||
margin: 4px; | ||
} | ||
} | ||
} | ||
& .is-stuck { | ||
position: fixed; | ||
z-index: var(--z-index-over-main); | ||
right: 10px; | ||
top: auto; | ||
bottom: 10px; | ||
-webkit-transform: none; | ||
-ms-transform: none; | ||
transform: none; | ||
border-radius: 0; | ||
display: block; | ||
-webkit-box-shadow: 0 2px 20px 0 rgba(0, 0, 0, 0.3); | ||
box-shadow: 0 2px 20px 0 rgba(0, 0, 0, 0.3); | ||
width: 40%; | ||
height: calc(var(--height-viewer) - var(--height-bar)); | ||
|
||
& .structure-viewer-select { | ||
left: 1rem; | ||
} | ||
|
||
&.structure-icon { | ||
font-size: 1em; | ||
} | ||
|
||
&.is-minimized { | ||
height: var(--height-bar); | ||
& .structure-viewer-ref { | ||
display: none; | ||
} | ||
} | ||
} | ||
} |
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.