Code Monkey home page Code Monkey logo

Comments (3)

mganjoo avatar mganjoo commented on August 25, 2024

Yep, this is achievable using "slots" - basically in gchessboard, any DOM element can be placed on a specific square by assigning the "slot" attribute.

In this case, your "background color of a specific square" can be achieved by thinking of it as a div overlay, with 100% width and height within a square, and styling that div with CSS.

Here's a quick CodePen with an example: https://codepen.io/mganjoo/pen/gOyGeOP

Is that what you were looking for?

from gchessboard.

szsascha avatar szsascha commented on August 25, 2024

Oh wow, thank you very much!
That's exactly what I'm looking for.

The documentation about the slots sounded to me like a layer above the pieces. So I though if I'm using this, the whole field is red and the piece will not be visible anymore because it's under the red layer.

But now it's a layer between the piece and the real background. So this is exactly what I'm looking for. Thanks a lot!

from gchessboard.

mganjoo avatar mganjoo commented on August 25, 2024

Yes, that's a good point! I should make that clear in the documentation - that was indeed the thinking when I designed this, that pieces would always be on top (though even with the slot element, you could manually "hack" it to show above pieces, with a high enough z-index actually this won't work - but also I don't yet have a situation where we'd want the piece to appear below a slotted overlay. If that need arises I'll look into it later).

Thanks for checking out the library!

from gchessboard.

Related Issues (19)

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.