Giter VIP home page Giter VIP logo

Comments (6)

tbranyen avatar tbranyen commented on June 4, 2024 1

@jlfwong That example I showed is using browser standards. Granted the diffHTML is my creation, but the following would also work:

import { StyleSheet, css } from 'aphrodite';

const styles = StyleSheet.create({
  red: {
    backgroundColor: 'red'
  },

  blue: {
    backgroundColor: 'blue'
  },

  hover: {
    ':hover': {
        backgroundColor: 'red'
    }
  },

  small: {
    '@media (max-width: 600px)': {
      backgroundColor: 'red',
    }
  }
});

class App extends HTMLElement {
  attachedCallback() {
    this.render();
  }

  render() {
    this.innerHTML = `
      <div>
        <span class="${css(styles.red)}">
            This is red.
        </span>
        <span class="${css(styles.hover)}">
            This turns red on hover.
        </span>
        <span class="${css(styles.small)}">
            This turns red when the browser is less than 600px width.
        </span>
        <span class="${css(styles.red, styles.blue)}">
            This is blue.
        </span>
        <span class="${css(styles.blue, styles.small)}">
            This is blue and turns red when the browser is less than
            600px width.
        </span>
      </div>
    `;
  }
}

document.registerElement('my-app', App);

Proving that no extra dependencies are necessary in order to use this library. Is there anything specific you'd like to see different, besides that it's a class extending an element with a render method?

from aphrodite.

jlfwong avatar jlfwong commented on June 4, 2024

Thanks! We did indeed design Aphrodite specifically with no dependency upon React.

I think this would be best accompanied by a more comprehensive example in the README of a non-React usage. I'm a bit reluctant to use the one you linked in the gist, as it looks very similar to React. I'd be leaning more towards something in higher usage and very non-React looking (notably not JSX). Perhaps handlebars would be a good choice, or even raw DOM manipulation.

Thoughts?

from aphrodite.

jlfwong avatar jlfwong commented on June 4, 2024

Ahh, I see! This is the first time I'm seeing a use of Web Components. If you could add to the attached diffs an example with an explanation that this is a Web Component with a link to the relevant spec (is it http://w3c.github.io/webcomponents/spec/custom/?). I think the example we use can be much simpler, since we're trying to demonstrate non-dependency on React, not trying to exercise the full feature set. Something like this, perhaps?

# Use without React

Aphrodite was built with React in mind, but does not depend on React. Here, you can see it
used with [Web Components][webcomponents]:

import { StyleSheet, css } from 'aphrodite';

const styles = StyleSheet.create({
  red: {
    backgroundColor: 'red'
  }
});

class App extends HTMLElement {
  attachedCallback() {
    this.innerHTML = `
      <div class="${css(styles.red)}">
        This is red.
      </div>
    `;
  }
}

document.registerElement('my-app', App);

[webcomponents]: http://w3c.github.io/webcomponents/spec/custom

If that appeals to you, then would you mind updating the diff with something similar to this?

from aphrodite.

tbranyen avatar tbranyen commented on June 4, 2024

Looks great to me, I'll update my PR, thanks!

from aphrodite.

tbranyen avatar tbranyen commented on June 4, 2024

FWIW I'm so out-of-the-loop with the current specification that I couldn't tell you where the canonical URL lives. At the very least this can give some direction and we can improve the link in the future.

from aphrodite.

tbranyen avatar tbranyen commented on June 4, 2024

https://github.com/tbranyen/aphrodite/blob/readme-phrasing/README.md Updated here, let me know if you have any feedback in the PR comments and I'll push up changes later.

from aphrodite.

Related Issues (20)

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.