Basic

Description: The value for the attachTo option property specifies a parent selector for the state pseudo-class condition to attach to.

Edit
// root === 0
ctr('.test', {
width: 200px
// .myKoolClass === 1
'component-.myKoolClass': {
size: 100px
// p === 2
'component-p': {
hover: {
on: {
option: {
// attach to .myKoolClass
attachTo: 1
}
color: red
}
non: {
option: {
// attach to root
attachTo: 0
}
color: blue
}
}
}
}
})
# root === 0
.test:
width: 200px
# .myKoolClass === 1
component-.myKoolClass:
size: 100px
# p === 2
component-p:
hover:
on:
option:
# attach to .myKoolClass
attachTo: 1
color: red
non:
option:
# attach to root
attachTo: 0
color: blue
.test {
width: 200px;
}
.test > .myKoolClass {
width: 100px;
height: 100px;
}
.test > .myKoolClass:hover > p {
color: #f00;
transition-delay: 0s;
transition-duration: 0.5s;
transition-property: color;
transition-timing-function: cubic-bezier(0.42, 0, 0.58, 1);
}
.test:not(:hover) > .myKoolClass > p {
color: #00f;
transition-delay: 0s;
transition-duration: 0.5s;
transition-property: color;
transition-timing-function: cubic-bezier(0.42, 0, 0.58, 1);
}
// root === 0
ctr('.test', {
  width: 200px
  // .myKoolClass === 1
  'component-.myKoolClass': {
    size: 100px
    // p === 2
    'component-p': {
      hover: {
        on: {
          option: {
            // attach to .myKoolClass
            attachTo: 1
          }
          color: red
        }
        non: {
          option: {
            // attach to root
            attachTo: 0
          }
          color: blue
        }
      }
    }
  }
})
.test {
  width: 200px;
}
.test > .myKoolClass {
  width: 100px;
  height: 100px;
}
.test > .myKoolClass:hover > p {
  color: #f00;
  transition-delay: 0s;
  transition-duration: 0.5s;
  transition-property: color;
  transition-timing-function: cubic-bezier(0.42, 0, 0.58, 1);
}
.test:not(:hover) > .myKoolClass > p {
  color: #00f;
  transition-delay: 0s;
  transition-duration: 0.5s;
  transition-property: color;
  transition-timing-function: cubic-bezier(0.42, 0, 0.58, 1);
}
# root === 0
.test:
  width: 200px
  # .myKoolClass === 1
  component-.myKoolClass:
    size: 100px
    # p === 2
    component-p:
      hover:
        on:
          option:
            # attach to .myKoolClass
            attachTo: 1
          color: red
        non:
          option:
            # attach to root
            attachTo: 0
          color: blue

Notes

String Key

Description: A String value can represent the attachTo target selector declaratively.

Edit
ctr('.test', {
width: 200px
'component-.myKoolClass': {
width: 100px
'component-span': {
hover: {
option: {
attachTo: '.myKoolClass'
}
on: {
opacity: 1
}
non: {
opacity: 0.5
}
}
}
}
})
.test:
width: 200px
component-.myKoolClass:
width: 100px
component-span:
hover:
option:
attachTo: .myKoolClass
on:
opacity: 1
non:
opacity: 0.5
.test {
width: 200px;
}
.test > .myKoolClass {
width: 100px;
}
.test > .myKoolClass:hover > span {
opacity: 1;
transition-delay: 0s;
transition-duration: 0.5s;
transition-property: opacity;
transition-timing-function: cubic-bezier(0.42, 0, 0.58, 1);
}
.test > .myKoolClass:not(:hover) > span {
opacity: 0.5;
transition-delay: 0s;
transition-duration: 0.5s;
transition-property: opacity;
transition-timing-function: cubic-bezier(0.42, 0, 0.58, 1);
}
ctr('.test', {
  width: 200px
  'component-.myKoolClass': {
    width: 100px
    'component-span': {
      hover: {
        option: {
          attachTo: '.myKoolClass'
        }
        on: {
          opacity: 1
        }
        non: {
          opacity: 0.5
        }
      }
    }
  }
})
.test {
  width: 200px;
}
.test > .myKoolClass {
  width: 100px;
}
.test > .myKoolClass:hover > span {
  opacity: 1;
  transition-delay: 0s;
  transition-duration: 0.5s;
  transition-property: opacity;
  transition-timing-function: cubic-bezier(0.42, 0, 0.58, 1);
}
.test > .myKoolClass:not(:hover) > span {
  opacity: 0.5;
  transition-delay: 0s;
  transition-duration: 0.5s;
  transition-property: opacity;
  transition-timing-function: cubic-bezier(0.42, 0, 0.58, 1);
}
.test:
  width: 200px
  component-.myKoolClass:
    width: 100px
    component-span:
      hover:
        option:
          attachTo: .myKoolClass
        on:
          opacity: 1
        non:
          opacity: 0.5

Notes

Previous

Description: The value of 'previous' can be used to attach to the previous parent selector.

Edit
ctr('.test', {
width: 200px
'component-.myKoolClass': {
width: 100px
'component-p': {
color: red
hover: {
option: {
attachTo: 'previous'
}
on: {
opacity: 1
}
non: {
opacity: 0.5
}
}
}
}
})
.test:
width: 200px
component-.myKoolClass:
width: 100px
component-p:
color: red
hover:
option:
attachTo: previous
on:
opacity: 1
non:
opacity: 0.5
.test {
width: 200px;
}
.test > .myKoolClass {
width: 100px;
}
.test > .myKoolClass > p {
color: #f00;
}
.test > .myKoolClass:hover > p {
opacity: 1;
transition-delay: 0s;
transition-duration: 0.5s;
transition-property: opacity;
transition-timing-function: cubic-bezier(0.42, 0, 0.58, 1);
}
.test > .myKoolClass:not(:hover) > p {
opacity: 0.5;
transition-delay: 0s;
transition-duration: 0.5s;
transition-property: opacity;
transition-timing-function: cubic-bezier(0.42, 0, 0.58, 1);
}
ctr('.test', {
  width: 200px
  'component-.myKoolClass': {
    width: 100px
    'component-p': {
      color: red
      hover: {
        option: {
          attachTo: 'previous'
        }
        on: {
          opacity: 1
        }
        non: {
          opacity: 0.5
        }
      }
    }
  }
})
.test {
  width: 200px;
}
.test > .myKoolClass {
  width: 100px;
}
.test > .myKoolClass > p {
  color: #f00;
}
.test > .myKoolClass:hover > p {
  opacity: 1;
  transition-delay: 0s;
  transition-duration: 0.5s;
  transition-property: opacity;
  transition-timing-function: cubic-bezier(0.42, 0, 0.58, 1);
}
.test > .myKoolClass:not(:hover) > p {
  opacity: 0.5;
  transition-delay: 0s;
  transition-duration: 0.5s;
  transition-property: opacity;
  transition-timing-function: cubic-bezier(0.42, 0, 0.58, 1);
}
.test:
  width: 200px
  component-.myKoolClass:
    width: 100px
    component-p:
      color: red
      hover:
        option:
          attachTo: previous
        on:
          opacity: 1
        non:
          opacity: 0.5

Notes