-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '23_2' into rm-typestat
- Loading branch information
Showing
198 changed files
with
3,980 additions
and
400 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
78 changes: 0 additions & 78 deletions
78
JSDemos/Demos/Common/DialogsAndNotificationsOverview/React/House.js
This file was deleted.
Oops, something went wrong.
93 changes: 93 additions & 0 deletions
93
JSDemos/Demos/Common/DialogsAndNotificationsOverview/React/House.tsx
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,93 @@ | ||
import React from 'react'; | ||
|
||
import Popover, { IPositionProps } from 'devextreme-react/popover'; | ||
|
||
const formatCurrency = new Intl.NumberFormat('en-US', { | ||
style: 'currency', | ||
currency: 'USD', | ||
minimumFractionDigits: 0, | ||
maximumFractionDigits: 2, | ||
}).format; | ||
|
||
const position: IPositionProps = { | ||
offset: '0, 2', | ||
at: 'bottom', | ||
my: 'top', | ||
collision: 'fit flip', | ||
}; | ||
|
||
interface HouseProps { | ||
house: { | ||
ID: string; | ||
Favorite: boolean; | ||
Address: string; | ||
City: string; | ||
State: string; | ||
ZipCode: string; | ||
Beds: string; | ||
Baths: string; | ||
HouseSize: number; | ||
LotSize: string; | ||
Price: number; | ||
Coordinates: string; | ||
Features: string; | ||
Image: string; | ||
Agent: { | ||
Name: string; | ||
Picture: string; | ||
Phone: string; | ||
} | ||
}; | ||
show: any; | ||
key: string; | ||
} | ||
|
||
export function House(props: HouseProps) { | ||
const renderAgentDetails = React.useCallback(() => { | ||
const agent = props.house.Agent; | ||
return ( | ||
<div className="agent-details"> | ||
<img alt={agent.Name} src={agent.Picture} /> | ||
<div> | ||
<div className="name large-text">{agent.Name}</div> | ||
<div className="phone">Tel: {agent.Phone}</div> | ||
</div> | ||
</div> | ||
); | ||
}, [props.house.Agent]); | ||
|
||
const show = React.useCallback(() => { | ||
props.show(props.house); | ||
}, [props]); | ||
|
||
return ( | ||
<div> | ||
<div onClick={show} className="item-content"> | ||
|
||
<img alt={props.house.Address} src={props.house.Image} /> | ||
|
||
<div className="item-options"> | ||
<div> | ||
<div className="address">{props.house.Address}</div> | ||
<div className="price large-text">{formatCurrency(props.house.Price)}</div> | ||
<div className="agent"> | ||
<div id={`house${props.house.ID}`}> | ||
<img alt="Listing agent" src="../../../../images/icon-agent.svg" /> | ||
Listing agent | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<Popover | ||
showEvent="mouseenter" | ||
hideEvent="mouseleave" | ||
position={position} | ||
target={`#house${props.house.ID}`} | ||
width={260} | ||
contentRender={renderAgentDetails} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
File renamed without changes.
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
2 changes: 1 addition & 1 deletion
2
.../Demos/HtmlEditor/Mentions/React/index.js → ...sAndNotificationsOverview/React/index.tsx
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
99 changes: 99 additions & 0 deletions
99
JSDemos/Demos/Common/DialogsAndNotificationsOverview/ReactJs/App.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,99 @@ | ||
import React from 'react'; | ||
import notify from 'devextreme/ui/notify'; | ||
import Button from 'devextreme-react/button'; | ||
import Popup from 'devextreme-react/popup'; | ||
import { housesSource } from './data.js'; | ||
import { House } from './House.js'; | ||
|
||
const ADD_TO_FAVORITES = 'Add to Favorites'; | ||
const REMOVE_FROM_FAVORITES = 'Remove from Favorites'; | ||
const formatCurrency = new Intl.NumberFormat('en-US', { | ||
style: 'currency', | ||
currency: 'USD', | ||
minimumFractionDigits: 0, | ||
maximumFractionDigits: 2, | ||
}).format; | ||
const favButtonAttrs = { | ||
class: 'favorites', | ||
}; | ||
export default function App() { | ||
const [currentHouse, setCurrentHouse] = React.useState(housesSource[0]); | ||
const [popupVisible, setPopupVisible] = React.useState(false); | ||
const renderPopup = React.useCallback( | ||
() => ( | ||
<div className="popup-property-details"> | ||
<div className="large-text">{formatCurrency(currentHouse.Price)}</div> | ||
<div className="opacity"> | ||
{currentHouse.Address}, {currentHouse.City}, {currentHouse.State} | ||
</div> | ||
<Button | ||
icon="favorites" | ||
text={currentHouse.Favorite ? REMOVE_FROM_FAVORITES : ADD_TO_FAVORITES} | ||
width={260} | ||
height={44} | ||
elementAttr={favButtonAttrs} | ||
onClick={changeFavoriteState} | ||
/> | ||
<div className="images"> | ||
<img | ||
alt={currentHouse.Address} | ||
src={currentHouse.Image} | ||
/> | ||
<img | ||
alt={currentHouse.Address} | ||
src={currentHouse.Image.replace('.jpg', 'b.jpg')} | ||
/> | ||
</div> | ||
<div>{currentHouse.Features}</div> | ||
</div> | ||
), | ||
[currentHouse], | ||
); | ||
const showHouse = React.useCallback( | ||
(house) => { | ||
setCurrentHouse(house); | ||
setPopupVisible(true); | ||
}, | ||
[setCurrentHouse, setPopupVisible], | ||
); | ||
const handlePopupHidden = React.useCallback(() => { | ||
setPopupVisible(false); | ||
}, [setPopupVisible]); | ||
const changeFavoriteState = React.useCallback(() => { | ||
const updatedHouse = { ...currentHouse }; | ||
updatedHouse.Favorite = !updatedHouse.Favorite; | ||
setCurrentHouse(updatedHouse); | ||
notify( | ||
{ | ||
message: `This item has been ${ | ||
updatedHouse.Favorite ? 'added to' : 'removed from' | ||
} the Favorites list!`, | ||
width: 450, | ||
}, | ||
updatedHouse.Favorite ? 'success' : 'error', | ||
2000, | ||
); | ||
}, [currentHouse, setCurrentHouse]); | ||
return ( | ||
<div className="images"> | ||
{housesSource.map((h) => ( | ||
<House | ||
house={h} | ||
show={showHouse} | ||
key={h.ID} | ||
/> | ||
))} | ||
<Popup | ||
width={660} | ||
height={540} | ||
showTitle={true} | ||
title={currentHouse.Address} | ||
dragEnabled={false} | ||
hideOnOutsideClick={true} | ||
visible={popupVisible} | ||
onHiding={handlePopupHidden} | ||
contentRender={renderPopup} | ||
/> | ||
</div> | ||
); | ||
} |
72 changes: 72 additions & 0 deletions
72
JSDemos/Demos/Common/DialogsAndNotificationsOverview/ReactJs/House.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,72 @@ | ||
import React from 'react'; | ||
import Popover from 'devextreme-react/popover'; | ||
|
||
const formatCurrency = new Intl.NumberFormat('en-US', { | ||
style: 'currency', | ||
currency: 'USD', | ||
minimumFractionDigits: 0, | ||
maximumFractionDigits: 2, | ||
}).format; | ||
const position = { | ||
offset: '0, 2', | ||
at: 'bottom', | ||
my: 'top', | ||
collision: 'fit flip', | ||
}; | ||
export function House(props) { | ||
const renderAgentDetails = React.useCallback(() => { | ||
const agent = props.house.Agent; | ||
return ( | ||
<div className="agent-details"> | ||
<img | ||
alt={agent.Name} | ||
src={agent.Picture} | ||
/> | ||
<div> | ||
<div className="name large-text">{agent.Name}</div> | ||
<div className="phone">Tel: {agent.Phone}</div> | ||
</div> | ||
</div> | ||
); | ||
}, [props.house.Agent]); | ||
const show = React.useCallback(() => { | ||
props.show(props.house); | ||
}, [props]); | ||
return ( | ||
<div> | ||
<div | ||
onClick={show} | ||
className="item-content" | ||
> | ||
<img | ||
alt={props.house.Address} | ||
src={props.house.Image} | ||
/> | ||
|
||
<div className="item-options"> | ||
<div> | ||
<div className="address">{props.house.Address}</div> | ||
<div className="price large-text">{formatCurrency(props.house.Price)}</div> | ||
<div className="agent"> | ||
<div id={`house${props.house.ID}`}> | ||
<img | ||
alt="Listing agent" | ||
src="../../../../images/icon-agent.svg" | ||
/> | ||
Listing agent | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<Popover | ||
showEvent="mouseenter" | ||
hideEvent="mouseleave" | ||
position={position} | ||
target={`#house${props.house.ID}`} | ||
width={260} | ||
contentRender={renderAgentDetails} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.