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

Updated Lazy document to handle viewing PDF's without downloading. #253

Merged
merged 7 commits into from
Feb 21, 2024

Conversation

lwjameson
Copy link
Contributor

In this PR

  • Added ViewPDFButton which accepts a redirect URL to view a PDF
  • Refactored LazyDocument to include an option to allow viewing of a PDF
  • Refactored LazyDocument to not use CSS files imported from node_modules (https://nextjs.org/docs/messages/css-npm)
    • Not really sure if this is the best approach to get around this issue but have not found anything else that will successfully build the NextJS app.

@@ -0,0 +1,329 @@
/* Copyright 2014 Mozilla Foundation
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to find an example of another component that imports CSS from node_modules. Would this type of setup work (plus the customization in Webpack config?):

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will give it a try. I will need to publish a new version to test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That did work. Updating.

@@ -25,7 +29,7 @@ const FacetSlider = forwardRef(({ useRangeSlider, ...props }: Props, ref: HTMLEl
refine,
} = useRangeSlider(props);

const [valueView, setValueView] = useState<Array<number>>([range.min, range.max]);
const [valueView, setValueView] = useState < Array < number >> ([range.min, range.max]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we preserve the current spacing rules? I'm not sure if this is a Prettier/ESLint issue, or something else.

@@ -72,12 +76,12 @@ const FacetSlider = forwardRef(({ useRangeSlider, ...props }: Props, ref: HTMLEl
columns={2}
>
<Grid.Column>
{ valueView[0] }
{valueView[0]}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a style guide I can use in VSCode? This I believe is the default ruleset of the VSCode formatter it is using as I do not have prettier activated right now...Though I think we should use it ;-)

packages/semantic-ui/src/components/LazyDocument.js Outdated Show resolved Hide resolved
@@ -26,6 +31,8 @@ type Props = {
image?: any,
pdf?: boolean,
preview?: ?string,
view?: Boolean,
view_url?: String,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use camel-case prop names for consistency with other components.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

*
* @type {string}
*/
const className = useMemo(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of these props can be passed to the Button component as props, instead of concatenting them as a class name. I'm wondering if this needs to be it's own component or can be done inline in the LazyDocument:

<Button
  basic
  content={...}
  primary
  icon='file pdf'
  onClick={...}
/>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a copy/paste of the DownloadButton component as a starting point. I switched from using an anchor to see if I could resolve an earlier issue. I use this button outside of LazyDocument in the ArchNet client so I think it makes sense to keep it as a functional component, but I could definitely refactor the classname stuff. Do not know if it is a priority right now.

@lwjameson lwjameson merged commit 2600e8e into master Feb 21, 2024
1 check passed
@lwjameson lwjameson deleted the feat/pdf-viewer branch February 21, 2024 22:15
@dleadbetter dleadbetter added the v1.1.4 Issues in v1.1.4 label Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v1.1.4 Issues in v1.1.4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants