Cursor rule
.cursor/rules/view_conventions.mdc[object Object]
Cursor rules
Quality
52/100
Scores the file, not the repository.Length
524 words
0 headings · 3 code blocksRepository
9.3k
— · pushed 0 days agoLast changed
2 days ago
First indexed 2 days ago.123456Use this rule to learn how to write ERB views, partials, and Stimulus controllers should be incorporated into them.78- **Component vs. Partial Decision Making**9 - **Use ViewComponents when:**10 - Element has complex logic or styling patterns11 - Element will be reused across multiple views/contexts12 - Element needs structured styling with variants/sizes (like buttons, badges)13 - Element requires interactive behavior or Stimulus controllers14 - Element has configurable slots or complex APIs15 - Element needs accessibility features or ARIA support1617 - **Use Partials when:**18 - Element is primarily static HTML with minimal logic19 - Element is used in only one or few specific contexts20 - Element is simple template content (like CTAs, static sections)21 - Element doesn't need variants, sizes, or complex configuration22 - Element is more about content organization than reusable functionality2324- **Prefer components over partials**25 - If there is a component available for the use case in app/components, use it26 - If there is no component, look for a partial27 - If there is no partial, decide between component or partial based on the criteria above2829- **Examples of Component vs. Partial Usage**30```erb31 <%# Component: Complex, reusable with variants and interactivity %>32 <%= render DialogComponent.new(variant: :drawer) do |dialog| %>33 <% dialog.with_header(title: "Account Settings") %>34 <% dialog.with_body { "Dialog content here" } %>35 <% end %>3637 <%# Component: Interactive with complex styling options %>38 <%= render ButtonComponent.new(text: "Save Changes", variant: "primary", confirm: "Are you sure?") %>3940 <%# Component: Reusable with variants %>41 <%= render FilledIconComponent.new(icon: "credit-card", variant: :surface) %>4243 <%# Partial: Static template content %>44 <%= render "shared/logo" %>4546 <%# Partial: Simple, context-specific content with basic styling %>47 <%= render "shared/trend_change", trend: @account.trend, comparison_label: "vs last month" %>4849 <%# Partial: Simple divider/utility %>50 <%= render "shared/ruler", classes: "my-4" %>5152 <%# Partial: Simple form utility %>53 <%= render "shared/form_errors", model: @account %>54```5556- **Keep domain logic out of the views**57```erb58 <%# BAD!!! %>5960 <%# This belongs in the component file, not the template file! %>61 <% button_classes = { class: "bg-blue-500 hover:bg-blue-600" } %>6263 <%= tag.button class: button_classes do %>64 Save Account65 <% end %>6667 <%# GOOD! %>6869 <%= tag.button class: computed_button_classes do %>70 Save Account71 <% end %>72```7374- **Stimulus Integration in Views**75 - Always use the **declarative approach** when integrating Stimulus controllers76 - The ERB template should declare what happens, the Stimulus controller should respond77 - Refer to [stimulus_conventions.mdc](mdc:.cursor/rules/stimulus_conventions.mdc) to learn how to incorporate them into7879 GOOD Stimulus controller integration into views:8081```erb82 <!-- Declarative - HTML declares what happens -->8384 <div data-controller="toggle">85 <button data-action="click->toggle#toggle" data-toggle-target="button">Show</button>86 <div data-toggle-target="content" class="hidden">Hello World!</div>87 </div>88```8990- **Stimulus Controller Placement Guidelines**91 - **Component controllers** (in `app/components/`) should only be used within their component templates92 - **Global controllers** (in `app/javascript/controllers/`) can be used across any view93 - Pass data from Rails to Stimulus using `data-*-value` attributes, not inline JavaScript94 - Use Stimulus targets to reference DOM elements, not manual `getElementById` calls9596- **Naming Conventions**97 - **Components**: Use `ComponentName` suffix (e.g., `ButtonComponent`, `DialogComponent`, `FilledIconComponent`)98 - **Partials**: Use underscore prefix (e.g., `_trend_change.html.erb`, `_form_errors.html.erb`, `_sync_indicator.html.erb`)99 - **Shared partials**: Place in `app/views/shared/` directory for reusable content100 - **Context-specific partials**: Place in relevant controller view directory (e.g., `accounts/_account_sidebar_tabs.html.erb`)101102
Also in we-promise/sure
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| we-promise/sure.cursor/rules/api-endpoint-consistency.mdc · 9.3k | Cursor rules | styletesting-strategygitsecurity+2 | 57/100 | 2 days ago | |
| we-promise/sure.cursor/rules/cursor_rules.mdc · 9.3k | Cursor rules | no sections | 36/100 | 2 days ago | |
| we-promise/sure.cursor/rules/general-rules.mdc · 9.3k | Cursor rules | styledo-not | 44/100 | 2 days ago | |
| we-promise/sure.cursor/rules/project-conventions.mdc · 9.3k | Cursor rules | styledependenciesdatabaseui+2 | 59/100 | 2 days ago | |
| we-promise/sure.cursor/rules/project-design.mdc · 9.3k | Cursor rules | style | 58/100 | 2 days ago | |
| we-promise/sure.cursor/rules/self_improve.mdc · 9.3k | Cursor rules | no sections | 36/100 | 2 days ago | |
| we-promise/sure.cursor/rules/stimulus_conventions.mdc · 9.3k | Cursor rules | no sections | 44/100 | 2 days ago | |
| we-promise/sure.cursor/rules/testing.mdc · 9.3k | Cursor rules | styletesting-strategy | 52/100 | 2 days ago | |
| we-promise/sure.cursor/rules/ui-ux-design-guidelines.mdc · 9.3k | Cursor rules | styledo-not | 49/100 | 2 days ago | |
| we-promise/sure.github/copilot-instructions.md · 9.3k | Copilot instructions | setuptestlint-formatstyle+10 | 88/100 | 2 days ago | |
| we-promise/sureAGENTS.md · 9.3k | AGENTS.md | buildtestlint-formatstyle+7 | 78/100 | 2 days ago | |
| we-promise/sureCLAUDE.md · 9.3k | CLAUDE.md | setuptestlint-formatstyle+11 | 93/100 | 2 days ago |
Diff against .cursor/rules/api-endpoint-consistency.mdc Diff against .cursor/rules/cursor_rules.mdc Diff against .cursor/rules/general-rules.mdc Diff against .cursor/rules/project-conventions.mdc Diff against .cursor/rules/project-design.mdc Diff against .cursor/rules/self_improve.mdc Diff against .cursor/rules/stimulus_conventions.mdc Diff against .cursor/rules/testing.mdc Diff against .cursor/rules/ui-ux-design-guidelines.mdc Diff against .github/copilot-instructions.md Diff against AGENTS.md Diff against CLAUDE.md
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| markstev/mark-starter.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+6 | 99/100 | 3 days ago | |
| Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| hiromaily/go-crypto-wallet.cursor/rules/proto.mdc · 126 | Cursor rules | buildlint-formatstylearch+3 | 96/100 | 3 days ago | |
| nerds-odd-e/doughnut.cursor/rules/cli.mdc · 49 | Cursor rules | setupbuildteststyle+4 | 96/100 | 3 days ago | |
| K-Mistele/opensearch.cursor/rules/default.mdc · 30 | Cursor rules | buildtestlint-formatstyle+2 | 94/100 | 3 days ago | |
| hiromaily/go-crypto-wallet.cursor/rules/task-context-loading.mdc · 126 | Cursor rules | archtypesdatabasedo-not+1 | 93/100 | 3 days ago |
