Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix label color of feedback button #2959

Merged
merged 2 commits into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions aries-site/src/components/feedback/FeedbackButton.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
import styled from 'styled-components';
import { useContext } from 'react';
import styled, { ThemeContext } from 'styled-components';
import PropTypes from 'prop-types';
import { Box, Button } from 'grommet';

const PositionedBox = styled(Box)`
position: fixed;
bottom: 0px;
border-radius: 6px;
right: 0px;
z-index: 10;
`;

export const FeedbackButton = ({ elevation, margin, ...buttonProps }) => (
<PositionedBox elevation={elevation} margin={margin}>
<Button {...buttonProps} />
</PositionedBox>
);
// temp fix until this theme issue is resolved:
// https://github.com/grommet/grommet-theme-hpe/issues/283
const StyledButton = styled(Button)`
color: ${props => props.theme.global.colors['text-strong'].dark};
`;

export const FeedbackButton = ({ elevation, margin, ...buttonProps }) => {
const theme = useContext(ThemeContext);
return (
<PositionedBox elevation={elevation} margin={margin}>
<StyledButton theme={theme} {...buttonProps} />
</PositionedBox>
);
};

FeedbackButton.propTypes = {
elevation: PropTypes.string,
margin: PropTypes.shape({}),
};
62 changes: 33 additions & 29 deletions aries-site/src/layouts/main/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,34 +78,37 @@ export const Layout = ({
}, 2000);
};

const onSubmit = useCallback(value => {
const data = {
values: {
fullURL: `https://design-system.hpe.design${router.route}`,
deviceType: 'desktop',
QID1: parseInt(value.value['like-rating']),
QID2_TEXT: value.value['text-area'],
},
};
// using next js env variables for url & api token
// https://nextjs.org/docs/basic-features/environment-variables
fetch(`${process.env.NEXT_PUBLIC_FEEDBACK_API_POST}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
'X-API-TOKEN': process.env.NEXT_PUBLIC_FEEDBACK_APP_API_TOKEN,
},
body: JSON.stringify(data),
})
.then(response => response.json())
.then(result => {
closeFeedbackModal();
const onSubmit = useCallback(
value => {
const data = {
values: {
fullURL: `https://design-system.hpe.design${router.route}`,
deviceType: 'desktop',
QID1: parseInt(value.value['like-rating'], 10),
QID2_TEXT: value.value['text-area'],
},
};
// using next js env variables for url & api token
// https://nextjs.org/docs/basic-features/environment-variables
fetch(`${process.env.NEXT_PUBLIC_FEEDBACK_API_POST}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
'X-API-TOKEN': process.env.NEXT_PUBLIC_FEEDBACK_APP_API_TOKEN,
},
body: JSON.stringify(data),
})
.catch(error => {
console.error('Error:', error);
});
}, []);
.then(response => response.json())
.then(() => {
closeFeedbackModal();
})
.catch(error => {
console.error('Error:', error);
});
},
[router.route],
);

const match = siteContents.find(item =>
item?.name === 'Index'
Expand Down Expand Up @@ -204,7 +207,7 @@ export const Layout = ({
color="purple!"
label="Feedback"
primary
a11yTitle={`This button launches a modal to give feedback.`}
a11yTitle="This button launches a modal to give feedback."
/>
<Feedback
show={open}
Expand All @@ -228,7 +231,8 @@ export const Layout = ({
kind="textArea"
label="Any additional comments?"
formProps={{
help: `Here's your chance to tell us your thoughts about this page.`,
help: `Here's your chance to tell us your thoughts
about this page.`,
}}
/>
</Feedback>
Expand Down
Loading