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

Example on codesandbox.io or similar #10

Open
wonderwhy-er opened this issue May 11, 2020 · 6 comments
Open

Example on codesandbox.io or similar #10

wonderwhy-er opened this issue May 11, 2020 · 6 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@wonderwhy-er
Copy link

Is your feature request related to a problem? Please describe.
Tried to use but did not understood how.

Describe the solution you'd like
Code example that can be played with on some online code playground like https://codesandbox.io/

@rsify rsify added documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels May 11, 2020
@JensUweB
Copy link

I don't know what frontend framework / library you're using, but in angular the implementation is dead simple:

  • Install package: npm install @gripeless/pico
  • add Window to providers array in AppModule:
@NgModule({
  declarations: [
    // Components
    AppComponent,
  ],
  imports: [
   //..
 ],
  providers: [{ provide: Window, useValue: window }],
  bootstrap: [AppComponent],
})
export class AppModule {}
  • take a picture
import * as Pico from '@gripeless/pico';

@Injectable({
  providedIn: 'root',
})
export class TicketService {
async doScreenShot() {
    // ...
    const screenshot = (await Pico.dataURL(window, {})).value;
    console.log(screenshot ); // for debugging only
    return screenshot;
  }
}

If you don't know angular: It uses not normal javascript, but its superset typescript.

@wonderwhy-er
Copy link
Author

Well reason I asked for this is that I did fail to make it work in some simple case.
Like here create vanilla typescript project on codesandbox and added just your import example.
https://codesandbox.io/s/vibrant-euclid-hxfxz?file=/src/index.ts

Could be problem with how they package.
But neither it works on RunKit to which you can go from npm page.
https://npm.runkit.com/%40gripeless%2Fpico

So yeah I asked for some example project that has both code and published online to play around.

@jamesta696
Copy link

Thanks for routing me to this example thread, unfortunately all examples are not working, resulting in "SyntaxError: Unexpected token" or "$csb__fluture.parallel is not a function".

@TomasKovacikArtin
Copy link

@JensUweB and what abotu the ignore option? Its failing if I provide { ignore: ['#to-ignore']}

@marcusx2
Copy link

Can any kind soul provide me the minified js file of this library?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

7 participants
@wonderwhy-er @marcusx2 @rsify @jamesta696 @TomasKovacikArtin @JensUweB and others