0

I want to be able to display a grid row gap if test.space_above = true on the data I am mapping over.

 {sortedUnitTestTemplates.map(test =>
      <div key={test.id} className='Table CreateUnitTestsGrid' style={{cursor: 'pointer'}} onClick={() => onTestTypeClick(test.id)}>


        <div>{test.test_type}</div>
        <div style={{width: '150px'}}>
          {!test.typical_dq_domain ? null :
            <Chip 
              label={test.typical_dq_domain}
              className='Badge' 
              style={{
                width: '100%', 
                color: getColor('fg', test.typical_dq_domain), 
                backgroundColor: getColor('bg', test.typical_dq_domain)
              }}
            />
          }
        </div>
      </div>
    )}
  </div>
1

2 Answers 2

0

its a little unclear how and where you want this gap... But here I am adding margin:

{sortedUnitTestTemplates.map(test =>
      <div key={test.id} className='Table CreateUnitTestsGrid' style={{cursor: 'pointer'}} onClick={() => onTestTypeClick(test.id)}>


        <div>{test.test_type}</div>
        <div style={{width: '150px', marginTop: test.space_above ? '100px' : 0 }}>
          {!test.typical_dq_domain ? null :
            <Chip 
              label={test.typical_dq_domain}
              className='Badge' 
              style={{
                width: '100%', 
                color: getColor('fg', test.typical_dq_domain), 
                backgroundColor: getColor('bg', test.typical_dq_domain)
              }}
            />
          }
        </div>
      </div>
    )}
  </div>
Sign up to request clarification or add additional context in comments.

Comments

0
// { condition && function()}

{test.typical_dq_domain && 
    <Chip 
        label={test.typical_dq_domain}
        className='Badge' 
        style={{
           width: '100%', 
           color: getColor('fg', test.typical_dq_domain), 
           backgroundColor: getColor('bg', test.typical_dq_domain)
        }}
    />
}

u can also check this article 8 conditional rendering methods in React

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.