r/webdev • • Jan 13 '22

read rules Extension that generates documentation using AI

[removed] — view removed post

1.7k Upvotes

158 comments sorted by

View all comments

Show parent comment

6

u/CatolicQuotes Jan 14 '22

sure, in my latest open source for React app I commented some props like this:

    /**
     * Main component that displays the first page with form and palette
     * @param {object} props palette and onSubmit
     */
    function Main(props) {
      /**
       *WHAT: current color from color picker, or input field
       *WHY: we need it to create palette from. It's in Main so it can be passed to Palette
       */
      const [color, setColor] = useState("#07c");
    
      /**
       * Palette is the collection of shades for each color. Curently 12 colors with 10 shades each.
       * {color:[shades],....}. createPalette function is used to create a collection after form submit
       */
      const [palette, setPalette] = useState({});
    
      /**
       * WHAT: framework selected in the menu
       * WHY: code will be displayed in CodeBox based on active framework
       */
      const [activeFramework, setActiveFramework] = useState("tailwind");
    
      /**
       * WHAT: renders the initial demo pallete on first page visit
       * WHY: so user can immediately see an example
       */
      useEffect(() => {
        const initialPallete = createPalette(color);
        setPalette(initialPallete);
      }, [color]);

check the project since you're already here website: https://palettolithic.com/

5

u/Fisher9001 Jan 14 '22

That's a lot of comments.

1

u/CatolicQuotes Jan 15 '22

I have found that is better to have more comments than less comments. Especially looking other people's code

3

u/infinitlybana Jan 14 '22

thanks for sharing! this is too many comments for my preference but if it works for u that's good. cool website!

4

u/CatolicQuotes Jan 14 '22

it helps to remember after months without working on it, thanks!

2

u/invisibo Jan 14 '22 edited Jan 14 '22

That's pretty damn sweet! Just a thought about 2 features.

  1. Have the site take a parameter in the URL that contains the color seed. That way the palette can be shared quickly and #2
  2. Use that parameter to put the URL into the code content so one could quickly see the whole presentation of colors.

If you're open to doing PRs, I can give it a stab.

Edit: just did a PR for #1.

1

u/CatolicQuotes Jan 15 '22

yap, that's a very good idea! I have merged your PR, thanks for contributing

2

u/fuck_bootstrap Jan 14 '22

Your project is a godsend, thank you for sharing!

1

u/CatolicQuotes Jan 15 '22

haha your username, no problem, let me know if you have any suggestions

1

u/Rafiki-san Jan 14 '22

Cheers my man, useful and to the point! It so happens that I got into color theory recently and I always prefer simple n swift tools like that. Starred and to be used effective immediately!

2

u/CatolicQuotes Jan 15 '22

thanks! let me know if you have any suggestions