Amazon decreasing rating leetcode question to find periods in which rating consequetively decreases

Amazon Shopping recently launched a new item whose daily customer ratings for n days is represented by the array ratings. They monitor these ratings to identify
products that are not performing well. Find the number of groups that can be formed consisting of 1 or more consecutive days such that the rating continuously decreases over the days.

The rating is consecutively decreasing if it has the form: r, r – 1, r-2… and so on, where r is the rating on the first day of the group being considered. Two groups are considered different if they contain the ratings of different consecutive days.

Example
ratings = [4, 3, 5, 4, 3]

There are 9 periods in which the rating consecutively decreases.

5 one day periods: [4], [3], [5], [4], [3]

3 two day periods: [4, 3], [5, 4], [4, 3]

Function Description
Complete the function countDecreasing Ratings in the editor.

countDecreasingRatings contains one parameter:
int ratings[n]. customer ratings for n days

Returns
long. the number of valid groups of ratings

Constraints
• 1 <= n <= 10^5
• O <= ratings[i] <= 10^9

Input Format For Custom Testing

The first line contains an integer, n, the number of elements in ratings.
Each line i of the n subsequent lines (where 0 <= i < n) contains an integer that describes ratings[i].

Sample Case 0

Sample Input For Custom Testing
| STDIN | FUNCTION |
| —– | ——– |
| 3 | ratings[] size n = 3 |
| 2 | ratings [2, 1, 3] |
| 1 | |
| 3 | |

Sample Output
4
Explanation

There are 4 groups of continuously decreasing ratings: [2], [1], [3], [2, 1].

How would you go for a question like this?

Empty spaces added around HTML text when using Angular interpolation

Any idea why an empty space is added before text in HTML when using interpolation in Angular?

Exemple in my Angular HTML template:

<div class="info-title">
     {{ "Beds" }}
</div>

Result after ng serve:

<div _ngcontent-bej-c49="" class="info-title"> Beds </div>

You can see that some spaces are added before and after Beds.

Do you have any idea of what I could do to prevent those spaces from appearing?

This is an exemple and I’m aware that there’s no need to use an interpolation here.

Bundling pouchdb-adapter-memory with Rollup

I am attempting to use the memory adapter for PouchDB. I want to bundle my application (along with dependencies like Pouch and this adapter) using Rollup. In order to reduce this to a minimally reproducible issue imagine this is my application I want to bundle:

import PouchDB from 'pouchdb-browser'
import MemoryAdapterPlugin from 'pouchdb-adapter-memory'

PouchDB.plugin(MemoryAdapterPlugin)

Since I am using a node module I’m obviously going to need the rollup-node-resolve Rollup plugin. Also many of PouchDB’s dependent modules are in CJS format so I’m going to also need the rollup-node-commonjs Rollup plugin. Finally PouchDB makes use of some built-in Node modules (such as events) and the memory adapter even more (buffer, etc). I’m not sure these are used at runtime (it may be just in PouchDB’s code because it can work in Node or the browser) but to prevent a bundling error I’m going to also include the rollup-plugin-node-polyfills plugin but direct the resolve plugin to prefer built-ins to the browser target if they are needed and available.

With all that in place here is my rollup config:

import commonjs from '@rollup/plugin-commonjs'
import resolve from '@rollup/plugin-node-resolve'
import nodePolyfills from 'rollup-plugin-node-polyfills'

export default {
  input: 'index.js',
  output: {
    format: 'iife',
    name: 'app',
    file: 'bundle.js'
  },
  plugins: [
    nodePolyfills(),

    resolve({
      preferBuiltins: true,
      browser: true
    }),

    commonjs({
      dynamicRequireTargets: [
        'node_modules/memdown/*.js',
      ],
    }),
  ]
}

The dynamicRequireTargets option is added because without it I get some sort of circular dependency warning:

(!) Circular dependencies
node_modules/memdown/immediate-browser.js -> node_modules/memdown/immediate-browser.js
node_modules/memdown/immediate-browser.js -> /home/me/Data/Development/rollup-test/node_modules/memdown/immediate-browser.js?commonjs-proxy -> node_modules/memdown/immediate-browser.js

But even with that correction in place I still end up with the following error causing a failure to build the bundle:

[!] Error: 'default' is not exported by node_modules/ltgt/index.js, imported by node_modules/sublevel-pouchdb/lib/index.es.js
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module
node_modules/sublevel-pouchdb/lib/index.es.js (1:7)
1: import ltgt from 'ltgt';
          ^
2: import events from 'events';
3: import Codec from 'level-codec';
Error: 'default' is not exported by node_modules/ltgt/index.js, imported by node_modules/sublevel-pouchdb/lib/index.es.js

Reading this error it indicates that sublevel-pouch (and internal package for PouchDB) which is in ES format (as indicated by the .es.js) is importing the ltgt library with:

import ltgt from 'ltgt';

ltgt is in CJS format but that should be ok as the commonjs Rollup plugin should transform it to be in ES format. I think this specifically relates to the defaultIsModuleExports option which should cause the default property of the generated ES code to be equal to module.exports. This all seems right and therefore there should be a default.

I’m not sure if the problem is my Rollup config, my understanding of CJS and ES format or it’s a bug in PouchDB. Any direction is appreciated!

script stops working on second loop(modal)

I have a script to add or remove a number. This is working on the first modal but on the second model it stops working. I think it might have to do with the window onload taking the first id and then the second time it stops? How to solve this ? if i make the id’s variable the script will not find the id’s…

script

window.onload=function(){
    var minusBtn = document.getElementById("minus"),
        plusBtn = document.getElementById("plus"),
        numberPlace = document.getElementById("numberPlace"),
        submitBtn = document.getElementById("submit"),
        number = 0, /// number value
        min = 0, /// min number
        max = 30; /// max number

    minusBtn.onclick = function(){
        if (number>min){
            number = number-1; /// Minus 1 of the number
            numberPlace.innerText = number ; /// Display the value in place of the number

        }
        if(number === min) {
            numberPlace.style.color= "red";
            setTimeout(function(){numberPlace.style.color= "black"},500)
        }
        else {
            numberPlace.style.color="black";
        }

    }
    plusBtn.onclick = function(){
        if(number<max){
            number = number+1;
            numberPlace.innerText = number ; /// Display the value in place of the number
        }
        if(number === max){
            numberPlace.style.color= "red";
            setTimeout(function(){numberPlace.style.color= "black"},500)
        }

        else {
            numberPlace.style.color= "black";

        }


    }
    submitBtn.onclick = function(){

        if (number > 1){
            alert( number + " items " + " has been added to basket");
        }else{
            alert( number + " item " + " has been added to basket");
        }
    }

}

Laravel blade page (see id Maindiv)

@extends('frontend.index')
@section('content')
    @foreach($products as $product)
        <article class="col-12 col-lg-3 d-flex justify-content-center mb-2 sbcard1 ">

            <div class="card text-center sbcardhome" style="width: 18rem;">
                <a href="{{route('frontend.detailpage', $product)}}"><img
                        src="{{$product->photo ? asset($product->photo->file) : 'http://via.placeholder.com/62'}}"
                        class="card-img-top img-fluid" alt="{{$product->name}}"></a>
                <div class="card-body">
                    <a id="brownbear" href="{{route('frontend.detailpage', $product)}}"><h5
                            class="card-title fs-6">{{$product->name}}</h5></a>
                    <a id="brownbearprice" href="{{route('frontend.detailpage', $product)}}"><p
                            class="card-text fw-bold">&#8364; {{$product->price}}</p></a>

                    <button type="button" class="btn btn-danger text-center mt-lg-3">Add To Cart</button>

                    <div class="box1" id="ease-in1">
                        <ul class="add-to-links1">
                            <li class="mb-3">
                                <a title="Add to wishlist" href="#"><i class="bi bi-heart  text-black"></i></a>
                            </li>

                            <li class="compare mb-3">
                                <a title="Add to compare" href="#" class=""><i
                                        class="bi bi-arrow-clockwise   text-black"></i></a>
                            </li>

                            <li class="quick-view mb-1">
                                <a data-bs-toggle="modal" data-bs-target="#staticBackdrop{{$product->id}}"
                                   title="Quick view" class="quick_view" href="#"><i
                                        class="bi bi-eye text-black"></i></a>
                            </li>
                        </ul>

                        <div class="modal fade" id="staticBackdrop{{$product->id}}" data-bs-backdrop="static"
                             data-bs-keyboard="false" tabindex="-1"
                             aria-labelledby="staticBackdropLabel{{$product->id}}" aria-hidden="true">
                            <div class="modal-dialog modal-lg">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <h5 class="modal-title"
                                            id="staticBackdropLabel{{$product->id}}">{{$product->name}}</h5>
                                        <button type="button" class="btn-close" data-bs-dismiss="modal"
                                                aria-label="Close"></button>
                                    </div>
                                    <div class="modal-body ">
                                        <article id="detail" class="container my-5 popreg">
                                            <div class="row">
                                                <div class="d-flex">
                                                    <div class="col-lg-6">

                                                        <img class="img-fluid" id="custommug"
                                                             src="{{$product->photo ? asset($product->photo->file) : 'http://via.placeholder.com/62'}}"
                                                             alt="customizable">
                                                    </div>
                                                    <div class="col-lg-6 text-center text-lg-start">
                                                        <h1 class="fs-3 my-3">{{$product->name}}</h1>
                                                        <p><small><span
                                                                    class="popbold">Reference: </span>{{$product->id}}
                                                            </small></p>
                                                        <p class="popbold fs-3 my-3">&#8364; {{$product->price}}</p>
                                                        <p class="fs-6">{{$product->description}}</p>
                                                        <hr>

                                                        <div id="detailaddtocart" class="row my-2">

                                                            <div id="mainDiv" class="col-lg-3 my-lg-2 col-4 ">
                                                                <button id="minus">-</button>
                                                                <span id="numberPlace">0</span>
                                                                <button id="plus">+</button>
                                                            </div>
                                                            <div class="col-lg-9 col-8 ">
                                                                <button id="submit"
                                                                        class="btn btn-danger add-to-cart my-lg-2"
                                                                        data-button-action="add-to-cart" type="submit">
                                                                    <i class="bi bi-plus-circle"></i>
                                                                    Add to cart
                                                                </button>
                                                            </div>
                                                        </div>
                                                        <div class="row my-3 ">
                                                            <div class="col-lg-4 col-6"><i
                                                                    class="bi bi-suit-heart me-lg-2"></i><a
                                                                    id="detailwish" href="#">Add to wishlist</a></div>
                                                            <div class="col-lg-8 col-6"><i
                                                                    class="bi bi-arrow-clockwise me-lg-2  text-black"></i><a
                                                                    id="detailcompare" href="#">Add to compare</a></div>
                                                        </div>
                                                        <div class="row">
                                                            <div class="col-lg-12 fs-4">
                                                                <p class="popbold">Share</p>
                                                                <a id="facebook" href="#"><i
                                                                        class=" bi bi-facebook mx-2 "></i></a>
                                                                <a id="twitter" href="#"><i
                                                                        class="bi bi-twitter mx-2 "></i></a>
                                                                <a id="google" href="#"><i
                                                                        class="bi bi-google mx-2 "></i></a>
                                                                <a id="instagram" href="#"><i
                                                                        class="bi bi-instagram mx-2 "></i></a>
                                                            </div>
                                                        </div>

                                                    </div>
                                                </div>
                                            </div>
                                        </article>
                                    </div>
                                </div>
                            </div>

                        </div>
                    </div>
                    <p class="discountbtn">{{$product->brand->name}}</p>
                    <p class="new">{{$product->category->name}}</p>
                </div>
            </div>
        </article>
    @endforeach
@endsection

enter image description here

PUT request BSONTypeError: Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer

I am trying to send a PUT request to the API but I get an error. I tried casting in DAO file but wasn’t helpful. I tried the other solutions to this issue but nothing could help me.

json data

{   
"citizen_id": "62595e0a2bcb1344ed6ab683",
"user_id": "1320",
"name": "cctyv tesey",
"email": "[email protected]",
"password": "abc123",
"nic": "921242340V",
"qualification": "a level",
"username": "tesy123",
"address": "4/3, isurupura road, kothalwala, kaduwela",
"profession": "software developer"}

citizenDAO.js

static async updateCitizens(userId, citizenId, date) {
    try {
      const updateCitizen = await citizens.updateOne(
        { user_id:userId,_id: ObjectId(citizenId)
        },
        { $set: { date: date  } },
      )

      return updateCitizen
    } catch (e) {
      console.error(`Unable to update the citizen: ${e}`)
      return { error: e }
    }
  }

citizen.controller.js

static async apiUpdateCitizens(req, res, next) {
try {
  const citizenId = req.body.citizen_id
  //const text = req.body.text
  const date = new Date()

  const citizenResponse = await CitizensDAO.updateCitizens(
    
    citizenId,
    req.body.user_id,
    date,
  )
  var { error } = citizenResponse
  if (error) {
    console.error(`Unable to update the citizen: ${error}`)
  } 

  if (citizenResponse.modifiedCount === 0) {
    throw new Error(
      "unable to update citizen - user may not be same",
    )
  }

  res.json({ status: "success" })
} catch (e) {
  res.status(500).json({ error: e.message })
}

}

How to push array of objects to a new array variable inside another object inside array by value?

I have 2 array that consist object :

a = 
[
 {
  id: 105647,
  name: 'name1'
 },
 {
  id: 105941,
  name: 'name2'
 },
 {
  id: 106177,
  name: 'name3'
 }
]

b = 
[
 {
  id: 105647,
  transactionDate: '2022-03-21',
  order: 1
 },
 {
  id: 105647,
  transactionDate: '2022-03-22',
  order: 2
 }
],
[
 {
  id: 106177,
  transactionDate: '2022-03-24',
  order: 1
 },
]

As you can see, that in b is not always have data for each id in variable a.

And my desired output would be

a = 
[
 {
  id: 105647,
  name: 'name1',
  dataB:
   [
    {
     id: 105647,
     transactionDate: '2022-03-21',
     order: 1
    },
    {
     id: 105647,
     transactionDate: '2022-03-22',
     order: 2
    }
   ]
 },
 {
  id: 105941,
  name: 'name2'
 },
 {
  id: 106177,
  name: 'name3',
  dataB: 
   [
    {
     id: 106177,
     transactionDate: '2022-03-24',
     order: 1
    },
   ]
  }
]

the b variable should be pushed to new variable dataB inside object of array on variable a. And if no dataB exist on a it would not create dataB on a / create the dataB but with empty array.

Please ask me if you need more information if it’s still not enough to solve that case.

Api response to data table

This is my postman collection which I want to show into my ajax data table.
I want to show few selected data from it.
I am getting this data in my ajax response but not able to show it in my table
My ajax code is this.

    "doc":[ {
                "billingDate": "2022-04-11T11:54:16.600Z",
                "_id": "6256ce0404de4671d565cca6",
                "serviceProvider": {
                    "blocked": false,
                    "isLoggedIn": true,
                    "createdDate": "2022-04-03T20:04:52.082Z",
                    "_id": "624a01981399dc7a14173dda",
                    "city": "Karachi",
                    "email": "[email protected]",
                    "password": "3460c98eec954a700b17bbac9f14b222",
                    "providerName": "Test Service",
                    "address": "123 Street",
                    "serviceProviderId": "TES321326",
                    "__v": 0
                },
                "services": [
                    {
                        "_id": "6256ce0404de4671d565cca7",
                        "serviceName": "husnain",
                        "actualCost": 60,
                        "discountedCost": 60
                    },
                    {
                        "_id": "6256ce0404de4671d565cca8",
                        "serviceName": "husnain",
                        "actualCost": 60,
                        "discountedCost": 70
                    },
                    {
                        "_id": "6256ce0404de4671d565cca9",
                        "serviceName": "husnain",
                        "actualCost": 60,
                        "discountedCost": 80
                    }
                ],
                "total": 210,
                "company": {
                    "blocked": false,
                    "isLoggedIn": false,
                    "createdDate": "2022-04-03T12:14:51.356Z",
                    "_id": "62498fc7acd7fb091185b88d",
                    "email": "[email protected]",
                    "companyName": "Yozio",
                    "address": "1 Buhler Road",
                    "image": "http://dummyimage.com/327x225.png/dddddd/000000",
                    "companyId": "UDB21WROMBA8",
                    "password": "3460c98eec954a700b17bbac9f14b222",
                    "__v": 0
                },
                "employee": {
                    "createdDate": "2022-04-03T17:09:47.994Z",
                    "enabled": true,
                    "_id": "6249d52bfef2560326a740e7",
                    "fName": "James Bartley",
                    "age": 30,
                    "CNIC": "3974224221510",
                    "spouse": "Hilary",
                    "fatherName": "James",
                    "motherName": "Brunhilde",
                    "employeeImage": "http://dummyimage.com/267x237.png/ff4444/ffffff",
                    "employeeID": "YO550717",
                    "company": "62498fc7acd7fb091185b88d",
                    "children": [],
                    "__v": 0
                },
                "billId": "YOTE529822",
                "__v": 0
            },
]

I want to show employee name, Employee ID , Services array object. I am getting this data in response but not able to show this in my datatable.

$(document).ready(function() {
    $.ajax({

        type: "POST",
        contentType: "application/json",
        url: 'https://2057-185-202-239-227.ngrok.io/serviceprovider/billByServiceProvider',
        data: JSON.stringify({
                 serviceProvider: sessionStorage.getItem("Services_id"),
               }),
                dataType: "json",
        success:function(response){

                $('#example12').DataTable({

                    "ajax": 'response.doc'
                });

        }
    }); 
});

Yet again, CSS being problematic again

So basically this is Day 3 (other days, I pretty much did nothing to complete the game) of making a game from HTML5. So I’m making a moves system right now, and I guess I’m doing well? (mainly because I’m not sure if I provided the user with too many moves…) But the thing about it is that, I’m kinda having ANOTHER styling issue.

enter image description here

As you can see in the image: I’ve CLEARLY set dimensions up for the headerDisplay class/id, but NO, it goes out of the div’s dimensions and even goes on the grid. I’m also aiming for the time and moves text to be stuck right on top of the grid, similarly to how the word bank is stuck to the bottom of the grid.

I was also aiming for a button that says refresh right under the word bank, however no matter what I tried, the button would just be right the score text, which looks like this:

enter image description here

When I am aiming for this:

enter image description here

Can anyone please help me? All help is appreciated.

Code:

<div class="content" id="content">
    <div class="headerDisplay" id="headerDisplay">
    </div>
    <div class="gameArea" id="gameArea">
    </div>
    <div class="wordBank" id="wordBank">
    </div>
    <div class="bottomMenu" id="bottomMenu">
    </div>
  </div>
::before,
    ::after {
      box-sizing: border-box;
      font-family: Arial, sans-serif;
      margin: 0;
      padding: 0;
    }
    .content {
      display: grid;
      grid-template-rows: repeat(3, max-content);
      margin-block: 1em;
      margin-inline: auto;
      width: 512px;
    }
    .bottomMenu {
      font-size: 24px;
      text-align: right;
    }
    .wordBank {
      border: 2.5px solid #000;
      border-radius: 5px;
      display: flex;
      font-size: 1.6em;
      min-height: 3em;
      justify-content: space-between;
      padding: 0.25em;
    }
    
    .wordBank span:nth-child(even) {
      align-self: end;
    }
    
    .gameArea {
      font-size: 0;
      justify-self: center;
      max-width: 100%;
    }
    
    .cell {
      border: 1px solid black;
      width: 50px;
      font-size: 1rem;
      height: 50px;
      display: inline-block;
    }

    .headerDisplay {
      width: 100%;
      height: 76.8px;
      text-align: right;
      font-size: 1.6em;
    }
let score = 0;
const headerDisplay = document.getElementById("headerDisplay")
const bottomMenu = document.getElementById("bottomMenu");
const wordBank = document.getElementById("wordBank")
const gameArea = document.getElementById("gameArea")
const rows = document.getElementsByClassName("gridRow");
const cells = document.getElementsByClassName("cell");
const words = [ // snippet
  "ability",
  "able",
  "about",
  "above",
  "abroad",
  "absence",
  "absent",
  "absolute",
  "accept",
  "accident",
  "accord",
  "account",
  "accuse",
  "accustom",
  "ache",
  "across",
  "act"
]
let selectedWords = [];
bottomMenu.innerHTML = "<p>Score: " + score;
bottomMenu.innerHTML += "<button>Refresh"
while (selectedWords.length < 5) {
  const selectedWord = words[Math.floor(Math.random() * words.length)];
  if (selectedWord.length <= 9) {
    wordBank.innerHTML += "<span>" + selectedWord + "</span>"
    selectedWords.push(selectedWord);
  }
}
let longestWord = selectedWords.reduce((a, b) => a.length < b.length ? b : a, "")
let charCount = longestWord.length
var moves = charCount * 5
headerDisplay.innerHTML += "<p>Time: "
headerDisplay.innerHTML += "<p>Moves: " + moves
function makeRows(rowNum) {
  for (let r = 0; r < rowNum; r++) {
    let row = document.createElement("div");
    gameArea.appendChild(row).className = "gridRow";
  }
}

function makeColumns(cellNum) {
  for (let i = 0; i < rows.length; i++) {
    for (let j = 0; j < cellNum; j++) {
      let newCell = document.createElement("div");
      rows[j].appendChild(newCell).className = "cell";
    }
  }
}

function defaultGrid() {
  makeRows(charCount);
  makeColumns(charCount);
}
defaultGrid();

Configure Next Js For Images For External Domains

I’m having an issue with next.config.js. I’m currently running a project with next js on typescript. In this project i am working with ThreeJs, @react-three/fiber & @react-three/drei. But I also want to include some images from a specific public YouTube url.
In older projects i have implemented this withought having ThreeJs inside like this:

module.exports = {
reactStrictMode: true,
images: {
    domains: ['i3.ytimg.com', 'img.youtube.com'],
    formats: ['image/webp'],
},

}

That being on my next.config.js and it still works like a charm. But when I put it in my current project and try to load an image I get error saying:

Error: Invalid src prop ([url]) on next/image, hostname “img.youtube.com” is not configured under images in your next.config.js

Current next.config.js file

module.exports = {
reactStrictMode: true,
images: {
    domains: ['i3.ytimg.com', 'img.youtube.com'],
    formats: ['image/webp'],
},
}


const withTM = require('next-transpile-modules')(['three', '@react-three/fiber', '@react-three/drei']);

module.exports = withTM();

On my component now:

export default function ProjectCard({ song }: { song: Lyrics }) {
const img = hqDefault(song.thumbnailURL);

return (
    <div>
        {song.singer}
        <Image src={img} alt={`${song.singer} ${song.title}`} layout="fill" />
    </div>
)
}

hqDefault Function:

export const hqDefault = (url: string): string => {
    return `https://img.youtube.com/vi/${url}/hqdefault.jpg`;
}

Any help will be appriciated!

Why does the filter: blur () disturb the normal behavior of the z-index of the pseudo element ::after? [duplicate]

Without filter: blur (1px) placed on the container everything works as expected (:: after is behind the container element due to the z-index: -1), but when I add it, something strange starts to happen. The pseudo element is still behind the text, button and input element, but not behind the container (“not behind the background color”). Does anyone know why this is happening? Would help a lot!

Here is the code: https://jsfiddle.net/2ntadghb/6/

HTML:

<div class="container">
   Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolor, exercitationem?
   <button>
     click it
   </button>
   <input type="text">
</div>

CSS:

.container {
  width: 200px;
  height: 200px;
  border: 1px solid black;
  background-color: #151515;
  margin: 20px auto;
  position: relative;
  color: white;
  
  filter: blur(1px);
}

.container::after {
  content: '';
  width: 100px;
  height: 100px;
  display: inline-block;
  background-color: red;
  position: absolute;
  z-index: -1;
  top: 0;
  left: 0;
}

The same problem also happens with -webkit-box-reflect: https://jsfiddle.net/2ntadghb/10/

CSS:

.container {
  width: 200px;
  height: 200px;
  border: 1px solid black;
  background-color: #151515;
  margin: 20px auto;
  position: relative;
  color: white;
  
  -webkit-box-reflect: below;
}

.container::after {
  content: '';
  width: 100px;
  height: 100px;
  display: inline-block;
  background-color: red;
  position: absolute;
  z-index: -1;
  top: 0;
  left: 0;
}

How to stretch the div across the entire width of the screen but aligning all items in the center?

So I have a Banner-component which I’m getting from a third party library.
This component creates a banner with an svg image in it (like a checkmark), some text and a closing button.

I need to style it some more so I’ve decided to wrap this component in my own div that I can style however I want.

Here’s my code:

<div style={{
    transition: 'opacity 1s ease',
    opacity: successBannerOpacity,
    position: 'fixed',
    top: '0',
    left: '0',
    width: '100%',
    zIndex: '9999',
    display: 'flex',
    justifyContent: 'center',
  }}>
    <Banner appearance="success" show closeHidden>
      De e-mail is verstuurd.
    </Banner>
  </div>

I want to style the banner to be on the top of my webpage and act as a “success” message if the user clicks on a button and an API call is a success. For appearing/disappearing I’m using the opacity & transition values.

I’m also trying to use flexbox to make it so that my div is the entire width of the screen, but the content of the Banner-component is in the center.

The Banner has an attribute “closeHidden” just to not show the closing button, because I have a setTimeout of 3 seconds that will fade it out again (using the transition & opacity).

Here’s how it looks now:

enter image description here

As you can see, the content itself is nicely in the center (also when I resize the page!) but the div/Banner is only as wide as it needs to be, instead of being 100% the width of my entire page!

Does anyone know how to use CSS and/or flexbox to get my desired result?

Trying to get base64 png image into p5.js image

So as the title says, i’m trying to load a base64 encoded png image into a p5js image, here’s a simplification of how im doing it:

PS: I’m using a base64 image because it’s generated from a server

var img;
function setup() {
  // Canvas setup code ....

  img = loadImage('loading.png'); // show an image which says that it's loading
  img.loadPixels();

  // More setup code ...
}


// ...

function draw() {
  image(img, 0, 0, img.width, img.height);
  // ... more code
}

// ...

function receivedCallback(data) { // This function gets called once we receive the data
  // Data looks like this: { width: 100, height: 100, data: "...base64 data...." }
  img.resize(data.width, data.height);
  var imgData = data.data;
  var imgBlob = new Blob([imgData], { type: "image/png" }); // Create a blob
  var urlCreator = window.URL || window.webkitURL;
  var imageUrl = urlCreator.createObjectURL(imgBlob); // Craft the url
  img.src = imageUrl;
  img.loadPixels();
  img.updatePixels();
}

But, it’s not working which is why I am asking here.
If there is any way to do it I would appreciate it very much.
Thanks in advance.