-
Notifications
You must be signed in to change notification settings - Fork 151
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 #6541 from artsy/feat/FX-2193--viewing-room
[FX-2193] Viewing room display on show pages
- Loading branch information
Showing
16 changed files
with
1,001 additions
and
140 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 |
---|---|---|
@@ -1,22 +1,82 @@ | ||
import React from "react" | ||
import { Box, BoxProps, ResponsiveBox, Text } from "@artsy/palette" | ||
import { Box, BoxProps, MediumCard, ResponsiveBox, Text } from "@artsy/palette" | ||
import { createFragmentContainer, graphql } from "react-relay" | ||
import { ShowViewingRoom_show } from "v2/__generated__/ShowViewingRoom_show.graphql" | ||
import { RouterLink } from "v2/Artsy/Router/RouterLink" | ||
import { crop } from "v2/Utils/resizer" | ||
import { getTagProps } from "v2/Components/ViewingRoomCard" | ||
|
||
interface ShowViewingRoom extends BoxProps {} | ||
interface ShowViewingRoomProps extends BoxProps { | ||
show: ShowViewingRoom_show | ||
} | ||
|
||
export const ShowViewingRoom: React.FC<ShowViewingRoomProps> = ({ | ||
show, | ||
...rest | ||
}) => { | ||
const [{ node: viewingRoom }] = show.viewingRoomsConnection.edges | ||
|
||
const thumbnail = crop(viewingRoom.image.imageURLs.normalized, { | ||
width: 900, | ||
height: 1200, | ||
}) | ||
|
||
export const ShowViewingRoom = ({ ...rest }) => { | ||
return ( | ||
<Box {...rest}> | ||
<Text variant="mediumText" mb={1}> | ||
Viewing Room | ||
</Text> | ||
|
||
<ResponsiveBox | ||
bg="black10" | ||
borderRadius={4} | ||
maxWidth="100%" | ||
aspectWidth={3} | ||
aspectHeight={4} | ||
/> | ||
<ResponsiveBox maxWidth="100%" aspectWidth={3} aspectHeight={4}> | ||
<RouterLink to={viewingRoom.href}> | ||
<MediumCard | ||
width="100%" | ||
height="100%" | ||
image={thumbnail} | ||
title={viewingRoom.title} | ||
subtitle={show.partner?.name} | ||
tag={getTagProps( | ||
viewingRoom.status, | ||
viewingRoom.distanceToOpen, | ||
viewingRoom.distanceToClose | ||
)} | ||
/> | ||
</RouterLink> | ||
</ResponsiveBox> | ||
</Box> | ||
) | ||
} | ||
|
||
export const ShowViewingRoomFragmentContainer = createFragmentContainer( | ||
ShowViewingRoom, | ||
{ | ||
show: graphql` | ||
fragment ShowViewingRoom_show on Show { | ||
partner { | ||
... on Partner { | ||
name | ||
} | ||
... on ExternalPartner { | ||
name | ||
} | ||
} | ||
viewingRoomsConnection { | ||
edges { | ||
node { | ||
status | ||
distanceToOpen(short: true) | ||
distanceToClose(short: true) | ||
title | ||
href | ||
image { | ||
imageURLs { | ||
normalized | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`, | ||
} | ||
) |
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,63 @@ | ||
import React from "react" | ||
import { mount } from "enzyme" | ||
import { MockPayloadGenerator, createMockEnvironment } from "relay-test-utils" | ||
import { QueryRenderer, graphql } from "react-relay" | ||
import { ShowViewingRoomFragmentContainer as ShowViewingRoom } from "../Components/ShowViewingRoom" | ||
import { ShowViewingRoom_Test_Query } from "v2/__generated__/ShowViewingRoom_Test_Query.graphql" | ||
|
||
jest.unmock("react-relay") | ||
|
||
describe("ShowViewingRoom", () => { | ||
const getWrapper = (mocks = {}) => { | ||
const env = createMockEnvironment() | ||
|
||
const TestRenderer = () => ( | ||
<QueryRenderer<ShowViewingRoom_Test_Query> | ||
environment={env} | ||
variables={{}} | ||
query={graphql` | ||
query ShowViewingRoom_Test_Query { | ||
show(id: "xxx") { | ||
...ShowViewingRoom_show | ||
} | ||
} | ||
`} | ||
render={({ props, error }) => { | ||
if (props?.show) { | ||
return <ShowViewingRoom show={props.show} /> | ||
} else if (error) { | ||
console.error(error) | ||
} | ||
}} | ||
/> | ||
) | ||
|
||
const wrapper = mount(<TestRenderer />) | ||
|
||
env.mock.resolveMostRecentOperation(operation => | ||
MockPayloadGenerator.generate(operation, { | ||
...mocks, | ||
}) | ||
) | ||
wrapper.update() | ||
return wrapper | ||
} | ||
|
||
it("renders correctly", () => { | ||
const wrapper = getWrapper({ | ||
ViewingRoom: () => ({ | ||
title: "Example Viewing Room", | ||
status: "closed", | ||
}), | ||
Partner: () => ({ | ||
name: "Example Partner Name", | ||
}), | ||
}) | ||
|
||
const html = wrapper.html() | ||
|
||
expect(html).toContain("Example Viewing Room") | ||
expect(html).toContain("Example Partner Name") | ||
expect(html).toContain("Closed") | ||
}) | ||
}) |
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.