Combine product attribute based on selection and compatibility

I'm trying generate cross-dependent product attribute dropdown-list.

With chosen option (from dropdown list) system generate appropriate variant id (based on chosen product attribute combinations from droplist).

Example: https://imgur.com/a/fXIMIcf

We have product X with SIZE and COLOR:

  • 45mm, black
  • 45mm, green
  • 60mm, black
  • 80mm, black

When we chose size 45mm, COLOR attribute droplist needs to be updated to black and green. And when we chose 60mm there will be only black option in COLOR.

My question is - How is possible to get variant id based on my selection

If you know any demos, tutorials, i would be glad if you'd sent them to me.

Thank you.