Skip to content

Commit

Permalink
feat: allow for specifying a custom width for the profile popup
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyhogoboom committed Nov 22, 2024
1 parent 4dafa2b commit 1fd1f39
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 9 deletions.
14 changes: 8 additions & 6 deletions packages/web-shared/components/Profile/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import themeGet from '@styled-system/theme-get';
import { logout, useAuth } from '../../providers/AuthProvider';
import authSteps from '../Auth/authSteps';

const Profile = ({ theme, handleCloseProfile, ...rest }) => {
const Profile = ({ theme, handleCloseProfile, size, ...rest }) => {
const { currentUser } = useCurrentUser();
const { currentChurch } = useCurrentChurch();

Expand Down Expand Up @@ -83,11 +83,13 @@ const Profile = ({ theme, handleCloseProfile, ...rest }) => {
_: '0%',
sm: 'xxl',
}}
width={{
_: '100%',
sm: '350px',
md: '520px',
}}
width={
size ?? {
_: '100%',
sm: '350px',
md: '520px',
}
}
>
<Box display="flex" alignItems="center" justifyContent="end">
<Styled.CloseIcon onClick={handleCloseProfile}>
Expand Down
2 changes: 1 addition & 1 deletion packages/web-shared/components/Profile/Profile.styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Profile = withTheme(styled.div`
position: absolute;
transition: opacity 0.3s ease;
z-index: 9999;
right: 0;
right: -15px;
@media screen and (max-width: ${themeGet('breakpoints.sm')}) {
position: fixed;
Expand Down
4 changes: 3 additions & 1 deletion packages/web-shared/components/Profile/ProfileButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ const ProfileButton = (props) => {
</Box>
)}
</Box>
{showProfile ? <Profile handleCloseProfile={() => setShowProfile(false)} /> : null}
{showProfile ? (
<Profile handleCloseProfile={() => setShowProfile(false)} size={props.popupSize} />
) : null}
</Box>
);
};
Expand Down
2 changes: 1 addition & 1 deletion packages/web-shared/components/Searchbar/Searchbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ const Searchbar = (props = {}) => {
</Styled.InterfaceWrapper>
</Styled.Interface>
<Box p={16}>
<ProfileButton />
<ProfileButton popupSize={searchState.searchProfileSize} />
</Box>
</Box>
<SearchResults autocompleteState={autocompleteState} autocomplete={autocompleteInstance} />
Expand Down
1 change: 1 addition & 0 deletions packages/web-shared/embeds/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const Main = ({ type }) => {
type={widget.dataset.type}
church={widget.dataset.church}
searchFeed={widget.dataset.searchFeed}
searchProfileSize={widget.dataset.searchProfileSize}
featureFeed={widget.dataset.featureFeed}
modal={widget.dataset.modal}
emptyPlaceholderText={widget.dataset.emptyPlaceholderText}
Expand Down
1 change: 1 addition & 0 deletions packages/web-shared/providers/AppProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function AppProvider(props = {}) {
<SearchProvider
church={props.church}
searchFeed={props.searchFeed}
searchProfileSize={props.searchProfileSize}
customPlaceholder={props.customPlaceholder}
>
<ModalProvider>
Expand Down
2 changes: 2 additions & 0 deletions packages/web-shared/providers/SearchProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const SearchDispatchContext = createContext();
const initialState = {
church: null,
searchFeed: null,
searchProfileSize: null,
customPlaceholder: null,
loading: true,
};
Expand Down Expand Up @@ -37,6 +38,7 @@ function SearchProvider(props = {}) {
...initialState, // spread the original initialState object
church: props.church, // add church to state
searchFeed: props.searchFeed, // add search feed id to state
searchProfileSize: props.searchProfileSize, // specify a custom width for the profile popup
customPlaceholder: props.customPlaceholder, // add search custom placeholder to state
});

Expand Down
4 changes: 4 additions & 0 deletions web-embeds/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ function App() {
const searchFeed = searchElement
? searchElement.getAttribute("data-search-feed")
: null;
const searchProfileSize = searchElement
? searchElement.getAttribute("data-search-profile-size")
: null;
const church = churchElement
? churchElement.getAttribute("data-church")
: null;
Expand Down Expand Up @@ -57,6 +60,7 @@ function App() {
<AppProvider
church={church}
searchFeed={searchFeed}
searchProfileSize={searchProfileSize}
customPlaceholder={customPlaceholder}
usePathRouter={usePathRouter}
>
Expand Down

0 comments on commit 1fd1f39

Please sign in to comment.