GithubHelp home page GithubHelp logo

riccardoperra / codeimage Goto Github PK

View Code? Open in Web Editor NEW
1.2K 5.0 63.0 13.85 MB

A tool to beautify your code screenshots. Built with SolidJS and Fastify.

Home Page: https://codeimage.dev

License: MIT License

JavaScript 1.13% HTML 0.65% TypeScript 96.27% SCSS 1.01% Shell 0.01% MDX 0.94%
solid-js solid code editor screenshot snippets tweet sharing codesnippets beautiful

codeimage's Introduction

CodeImage logo

Create elegant code screenshots of your source code.

Latest release Version Build workflow badge Issues Built with SolidJS Built with Vanilla Extract License

Introduction

CodeImage is the newest tool to help developers to create beautiful screenshots of their code, providing several features to speed up the process to post in social media.

CodeImage - A tool to manage and beautify your code screenshots | Product Hunt

CodeImage showcase

πŸ€– Tech stack

CodeImage architecture consist of a PNPM monorepo, currently subdivided in packages and apps.

Apps

The front-end application, entirely built with SolidJS.

It currently also relies on these libraries:

The REST API layer built with Fastify, Prisma ORM and Auth0.

Packages

🌏 Contributions

Warning Read this before opening any PR!

When contributing, it's better to first discuss the change you wish to make via issue or discussion, or any other method with the owners of this repository before making a change.

See the CONTRIBUTING.md guide for more details.


CodeImage is the winner of SolidHack 2022 for the Best Application category!

License

MIT Β© Riccardo Perra

codeimage's People

Contributors

alexandercerutti avatar apollo79 avatar arstnei0 avatar endbug avatar github-actions[bot] avatar hackpirodev avatar jrafael91 avatar kalmarv avatar kriskw1999 avatar max-programming avatar riccardoperra avatar sarjuhansaliya avatar simran88 avatar tglide avatar vikki123 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

codeimage's Issues

Export action improvements

In desktop/mobile view, export button is only exporting the image, but no information about the extension or sizing are displayed. A dialog where these options will be settled could be useful

🐞- Link sharing

Already done in main/dev branch. Must investigate on WebShare API errors on iOS due to async task and font loading

πŸ€– - Investigate for presets

Presets are premade templates that user can create without any restriction. Presets will be built-in in the application providing settings adapted for Social media

πŸš€ - Code beautify

Code beautifier could not be available for all language. Must investigate to discover which tool can be used.

For html/js/css/ts there is prettier plugin

πŸš€ - Mobile lite view

Due to accessibility and issues related to frame scaling (#42) when opening the mobile version of the app there could be used a button that change the canvas view to a lite modality.

In the lite modality (<=749 width) only the Editor will be viewed, then the preview could be accessed clicking another action (or with the export button)

πŸš€ - Ui kit design tokens improvements

  • Adjust vanilla-extract duplicate styling in components
  • Provide better abstraction for base components to avoid style code duplication
  • Improve sprinkles and base component API
  • Provide better accessibility (see lighthouse)

OSS

  • create pr template
  • improve ci workflow
  • add contributing.md and code line-guides
  • Update README.md

πŸš€ - Moonlight Theme

This task consist of creating a new theme for CodeImage editor using CodeMirror API.

https://github.com/atomiks/moonlight-vscode-theme


Instructions for contributions

NOTE If your intention is to only develop a new theme, you don't need to use docker or install everything. You will work only on @codeimage/highlight package

  • Move to packages/highlight. You will see a How to create a new theme section in the README.md file .
  • Run the pnpm generate:theme script and put the moonlight theme name
  • Open the theme playground with pnpm dev (from the highlight package) or pnpm dev --filter=@codeimage/highlight (from the root folder)

For further help you can ask for help in the comments below

πŸš€ - Monokai Pro Theme

Color scheme https://monokai.pro/

This task consist of creating a new theme for CodeImage editor using CodeMirror API.


Instructions for contributions

NOTE If your intention is to only develop a new theme, you don't need to use docker or install everything. You will work only on @codeimage/highlight package

  • Move to packages/highlight. You will see a How to create a new theme section in the README.md file .
  • Run the pnpm generate:theme script and put the monokaiPro theme name
  • Open the theme playground with pnpm dev (from the highlight package) or pnpm dev --filter=@codeimage/highlight (from the root folder)

For further help you can ask for help in the comments below

πŸš€ - Shortcut hint toolbar

Commands:
F: focus text editor
Esc: unfocus text editor
B: toggle background
D: toggle dark mode
L: select programming language
Ctrl+S: export (check if should open dialog or export directly)
Ctrl+Shift+Ccopy link with share api
? open shortcut

πŸš€ - Mobile native inputs

Components like select, range, color must be native in mobile phones due to ux accessibility. In desktop modality there will be a custom component

🐞 - Broken code mirror cursor and line numbers on scaled content

Added to fix mobile editor cursor and gutter when scaling the content, should be removed since it is an experimental property.

Edit:
After an investigation, it seems that there is a browser issue with "getBoundingClientRects"that returns inconsistent values when the parent node has the transform scale property.

This could be fixed wrapping the scaled content into an iframe. This could be a possible implementation that doesn't cover these issues:

  • Stylesheet are not fully loaded. When switching a theme that uses @emotion/css the stylesheet must be loaded into the iframe.
  • Iframe position must be changered.
  • Frame handler size could be fixed

Possible implementation: create a new app package that handle only his style and the editor content

// IFrame.tsx

type IFrameProps = JSX.IntrinsicElements['iframe'] & {};

export function IFrame(props: IFrameProps): JSX.Element {
  const [ref, setRef] = createSignal<HTMLIFrameElement>();
  const [mountNode, setMountNode] = createSignal<HTMLElement>();
  const [height, setHeight] = createSignal(0);
  const [width, setWidth] = createSignal(0);

  createEffect(
    on(ref, frame => {
      if (!frame || !frame.contentWindow) return;
      const currentHead = window.document.head;
      frame.contentDocument!.head.innerHTML = currentHead.innerHTML;
      setMountNode(() => frame.contentWindow?.document.body);

      setTimeout(() => {
        const scrollHeight = ref()?.contentWindow?.document.body.scrollHeight;
        const scrollWidth = ref()?.contentWindow?.document.body.scrollWidth;
        setHeight(scrollHeight ?? 0);
        setWidth(scrollWidth ?? 0);
      });
    }),
  );

  return (
    <iframe {...props} ref={setRef} width={width()} height={height()}>
      <Show when={mountNode()}>
        {node => <Portal mount={node}>{props.children}</Portal>}
      </Show>
    </iframe>
  );
}
// FrameHandler.tsx

export function FrameHandler(
  props: PropsWithChildren<FrameHandlerProps>,
): JSXElement {
  const [internalRef, setInternalRef] = createSignal<HTMLDivElement>();
  const [canvasScale, setCanvasScale] = createSignal(1);
  const ratio = 0.1;

  createEffect(
    on([internalRef], ([frame]) => {
      setTimeout(() => {
        const scale = getScaleByRatio(
          // TODO: should be a ref (?)
          frame?.parentElement,
          frame,
          1 + ratio,
        );
        props.onScaleChange(scale);
        setCanvasScale(scale);
      });
    }),
  );

  return (
    <Box class={styles.wrapper}>
      <div
        class={styles.handler}
        style={assignInlineVars({
          [styles.frameHandlerVars.scale]: canvasScale().toString(),
        })}
        ref={createRef<'div'>(props, e => {
          setInternalRef(() => e);
        })}
      >
        <div use:exportExclude={true} class={styles.squaredBackgroundOverlay} />

        <IFrame>{props.children}</IFrame>
      </div>
    </Box>
  );
}

πŸš€ - Changelog and release automation

Planning:

Main will host beta.codeimage.dev
Release branches will host the new codeimage.dev

To deploy in production:

  • Add a workflow dispatch
  • Set git repo, use peter-evans/create-pull-request@v3 to create a new pull request for branch release/${{ steps.run-release.outputs.new_version }}

Theme API improvements

Currently creating new themes is β€œhard”, it’s a lot of copy paste and there isn’t a right api contract that all themes uses.

With this new Theme API, all themes must follow the same interface (palette, highlight color api) and extends the same default theme.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.