Skip to content

Commit

Permalink
Update with changes to image size (#1527)
Browse files Browse the repository at this point in the history
  • Loading branch information
louisachu committed Jul 14, 2023
1 parent 901459c commit 39a8e26
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion packages/gatsby-theme-aio/src/components/Context/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
import { createContext } from 'react';

const Context = createContext({});
const TableContext = createContext('');

export const Provider = Context.Provider;

export default Context;
export {Context as default, TableContext};
7 changes: 5 additions & 2 deletions packages/gatsby-theme-aio/src/components/Image/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
* governing permissions and limitations under the License.
*/

import React from 'react';
import React, {useContext} from 'react';
import { css } from '@emotion/react';
import { DESKTOP_SCREEN_WIDTH } from '../../utils';
import {TableContext} from "../Context";

export const Image = (props) => {
const {isTable} = useContext(TableContext);
// Check if gatsby-remark-images-remote processing was skipped
if (!props.src || props.src.default || props.src.endsWith('.svg') || props.src.endsWith('.gif') || !props.loading) {
// Defaults to same as gatsby-remark-images-remote loading config
Expand All @@ -40,7 +42,8 @@ export const Image = (props) => {
alt={props.alt}
className="gatsby-resp-image-image"
css={css`
width: 100%;
max-width: ${isTable ? '100%' : ''};
width: ${isTable ? '' : '100%'};
opacity: 1;
transition: opacity 0.5s;
`}
Expand Down
5 changes: 4 additions & 1 deletion packages/gatsby-theme-aio/src/components/Table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { css } from '@emotion/react';
import PropTypes from 'prop-types';
import '@spectrum-css/table';
import { MOBILE_SCREEN_WIDTH, useParentSize } from '../../utils';
import {TableContext} from '../Context';

const Table = ({ children, css: cssOverrides, columnWidths, ...props }) => {
const tableRef = useRef(null);
Expand Down Expand Up @@ -121,6 +122,8 @@ const Tr = ({ children, ...props }) => {
};

const Td = ({ children, ...props }) => {
const [isTable, setIsTable] = useState(true);

return (
<td
className="spectrum-Table-cell"
Expand All @@ -134,7 +137,7 @@ const Td = ({ children, ...props }) => {
css={css`
max-width: ${props.cellWidth}px;
`}>
{children}
<TableContext.Provider value={{ isTable, setIsTable }}>{children}</TableContext.Provider>
</div>
</td>
);
Expand Down

0 comments on commit 39a8e26

Please sign in to comment.