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

HEX colors for boards headers #177

Closed
Brecht272727 opened this issue Aug 29, 2022 · 2 comments
Closed

HEX colors for boards headers #177

Brecht272727 opened this issue Aug 29, 2022 · 2 comments

Comments

@Brecht272727
Copy link

Hi, is it possible to add a HEX color to the board header?
Now we use a class in the boards JSON but we need to add the color before in the css stylesheet.
It is better to have a different color attribute if we load the boards JSON.
Maybe there is a workaround?

@Brecht272727
Copy link
Author

Brecht272727 commented Sep 3, 2022

I found out myself how to do this. See the code below.
We send the boardId via the ajax to database and in success response we retrieve the board_header_background_color and board_header_text_color. It's all outside the library.

      function change_background_colors_boards() {
        var titles = document.getElementsByClassName("kanban-title-board");
        if (titles.length == 0) {
          return;
        }

        for (var column = 0; column < titles.length; column++) {
          let currentColumn = titles[column];
          let boardId = currentColumn.parentElement.parentElement.dataset.id;
          
          $.ajax({
              url: 'assets/ajax/kanban-fetch-background-colors-board-header.php',
              dataType: 'json',
              cache: false,
              data: {boardId: boardId},
              type: "POST",
              success: function (data) {
                $(currentColumn.parentElement).css("background-color", data.board_header_background_color);
                $(currentColumn.parentElement).css("color", data.board_header_text_color);
              },
              error: function (xhr, status, error) {
                  console.log('An error occurred');
                  var err = eval("(" + xhr.responseText + ")");
                  console.log(err);
              }
          });          
          
        }
      }

      change_background_colors_boards();

@asimp51
Copy link

asimp51 commented Nov 22, 2022

There is a better way instead of ajax call again and again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants